在6.0.1系统做定制相机开发,调用系统API CameraManager.getCameraList()。获取的cameraId数组为空。事实上设备是有一个摄像头的。为什么会拿不到?请教下是什么原因?有没有其他手段避开这个问题顺利完成相机定制?
PHP中文网2017-04-18 09:09:57
Without obtaining camera permission, the real phone displays two values 0 (Non-removable cameras use integers starting at 0 for their identifiers) and 1 (both front and rear cameras);
Official document What is shown above is CameraManager.getCameraIdList()
, not CameraManager.getCameraList(). CameraManager.getCameraIdList()
,而不是CameraManager.getCameraList(),
这个 API 是 Android 21 添加的,检查下 targetSdkVersion
This API was added in Android 21. Check whether targetSdkVersion
is lower than 21.