如何启动前置摄像头与意图是什么? [英] How to launch front camera with intent?
问题描述
我使用的意图,与本机应用程序打开摄像头:
I'm using an intent to open the camera with the native application:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri photoUri = Uri.fromFile(getOutputPhotoFile());
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
startActivityForResult(intent, CAMERA_PHOTO_REQUEST_CODE);
每次被打开(前/后摄像头)摄像头就像上一次出现这种内置相机应用程序是开放的。也就是说,如果我最后一次关闭了内置相机应用程序相机背面是积极的,所以当我启动意图摄像头,背部摄像头将被激活。
Every time the camera that is opened (front/back camera) is like the last time this native camera application was open. Meaning that if the last time I closed the native camera application the back camera was active, so when I launch the intent for camera, the back camera will be active.
我要直接启动前置摄像头的意图。是否有人知道如何做到这一点?
I want to launch directly the front camera with the intent. Does anybody know how to do that?
推荐答案
字谨慎:它是一个黑客
这加入的意图
intent.putExtra("android.intent.extras.CAMERA_FACING", 1);
这个解决方案是不可持续的,它使用相机应用程序的测试code。欲了解更多信息看看的Util类的AOSP相机项目的getCameraFacingIntentExtras静态方法。
This solution isn't sustainable, its using a testing code of the Camera app. For more info look at the "getCameraFacingIntentExtras" static method in Util class of the AOSP Camera project.
更新: 看起来像它在L的停用
Update: Looks like that it was disabled in L
这篇关于如何启动前置摄像头与意图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!