我试图用Intent
直接打开前置摄像头。以下是我的代码 -
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
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);
}
我的清单文件: -
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="some.package">
<uses-permission android:name="android.permission.INTERNET" />
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
此代码不适用于S6(7.0)。但它正在开发S5,S4,Nexus 6P(8.0)。
这是三星的某种错误,或者我的代码有问题。
我试图用Intent直接打开前置摄像头
Android SDK中没有任何内容。
以下是我的代码
Android有数百甚至数千种不同的相机应用程序。有些是预先安装的;一些是用户安装的。没有人必须尊重那些无证的Intent
演员。
此代码不适用于S6(7.0)。但它正在开发S5,S4,Nexus 6P(8.0)。
有大约20,000个Android设备型号。只有一些可能有一个预安装的相机应用程序,以纪念那些无证的Intent
额外。
这是三星的某种错误,或者我的代码有问题。
三星针对该特定设备的相机应用程序根本不尊重那些未记载的附加内容。