如何检测设备是否有后置摄像头?
这是我用来检测设备是否有手电筒的代码:
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)
|| (_camera.getParameters().getSupportedFlashModes() != null)) hasFlashlight = true;
else hasFlashlight = false;
即使设备只有前置摄像头而没有闪光灯,这也是真实的。
Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
只打开后置相机? - Yousha Aleayoubopen()
方法的参数不是像CAMERA_FACING_BACK
这样的属性。 - CommonsWare