【发布时间】:2013-06-21 06:42:15
【问题描述】:
我正在开发一个应用程序,我想在单击按钮时打开前置摄像头(如果该设备上存在前置摄像头)。
我已使用此代码,它适用于具有 OS 3.2.1 的华硕平板电脑。但是相同的代码在 OS 4.2.1 上不起作用。
我想要适用于所有 android 版本的代码。 请帮我解决这个问题。
以下是我的代码-
Intent takePictureIntent = new Intent(
MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(f));
Log.v("", "Camera Id-" + camId);
if (!TextUtils.isEmpty(camera)) {
if (camera.equalsIgnoreCase("Front")) {
Log.v("", "Inside if");
takePictureIntent.putExtra(
"android.intent.extras.CAMERA_FACING",
Camera.CameraInfo.CAMERA_FACING_FRONT);
} else {
Log.v("", "Inside else");
takePictureIntent.putExtra(
"android.intent.extras.CAMERA_FACING",
Camera.CameraInfo.CAMERA_FACING_BACK);
}
}
startActivityForResult(takePictureIntent, actionCode);
【问题讨论】:
-
你遇到了什么错误??我的意思是把你的logcat..
-
没有错误。它适用于 3.2.1 平板电脑(打开前置摄像头),但在其他版本上仅打开后置摄像头
-
你用的是什么设备..?
-
我用过AUSU平板A501型号
标签: android android-camera-intent