Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使用intent start前置摄像头?_Android_Camera - Fatal编程技术网

Android 如何使用intent start前置摄像头?

Android 如何使用intent start前置摄像头?,android,camera,Android,Camera,我尝试了其他问题的方法,但对我来说,这些方法不起作用 我想用intent启动前置摄像头。 我试着去做 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra("android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT); intent.putExtra("android.i

我尝试了其他问题的方法,但对我来说,这些方法不起作用

我想用intent启动前置摄像头。 我试着去做

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
intent.putExtra("android.intent.extras.LENS_FACING_FRONT", 1);
intent.putExtra("android.intent.extra.USE_FRONT_CAMERA", true);
mFile = Utils.getVisitorImage();
Uri imageUri = FileProvider.getUriForFile(
                getActivity(),
                getActivity().getPackageName() + ".fileprovider",
                mFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, CAMERA_PHOTO_REQUEST_CODE);
但是,它不起作用。 我的设备是安卓7.1.1。 如何使用intent start前置摄像头?
我希望有人能帮助我。谢谢。

AndroidManifest.xml
文件中添加以下权限:

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />

@你添加权限了吗?我尝试了其他的方法,但对我来说,这些方法不行work@kaihello我添加了权限,但仍然没有打开前置摄像头。始终是后置摄像头。这是摄像头问题,我换了一部手机它可以工作。我添加了权限,但仍然没有打开前置摄像头。你能在这里打印你的LogCat错误吗?我给了摄像头权限,所以这里没有错误的信息,肯定会给你的问题带来一些信息@kaihello
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);    
intent.putExtra("android.intent.extras.CAMERA_FACING", 1);