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 添加的,检查下 targetSdkVersionThis API was added in Android 21. Check whether targetSdkVersion is lower than 21.
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 whethertargetSdkVersion
is lower than 21.