Android 安卓上的开放式摄像机使用Intents

Android 安卓上的开放式摄像机使用Intents,android,android-camera,Android,Android Camera,使用此代码,我启动ANDROID摄像头: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name //

使用此代码,我启动ANDROID摄像头:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
但此代码会打开后摄像头。是否可以启动
Intent
以打开前置摄像头?

您可以尝试使用

intent.putExtra("android.intent.extras.CAMERA_FACING", 1);
这个答案需要注意的是,并非所有设备上的摄像头应用程序都是相同的,在许多设备中,默认的摄像头应用程序是由OEM开发的。所以这实际上是一个解决办法。我相信前置摄像头没有一个具体的API,因为许多应用程序可能会将其用于间谍和其他目的