Android: How can I check if a device has Camera2 api features implemented or not?

前端 未结 7 1095
孤独总比滥情好
孤独总比滥情好 2020-12-06 10:55

Well, how can I check if an android device has Camera2 api features implemented or not? There are many new features in camera2 api such as manual controls. So how can I know

7条回答
  •  长情又很酷
    2020-12-06 11:24

    Indeed, the camera2 api is only supported from API level 21. But only this check is not enough. There are devices with API level 21, but that support the camera 2 only partially. To check this, you should check the value of CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL. It can be FULL, LEGACY or LIMITED. Check here for details: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html

    Here is how to get it:

    CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
    
    for (String cameraId : manager.getCameraIdList()) {
                        CameraCharacteristics characteristics
                                = manager.getCameraCharacteristics(cameraId);
    
    
        Log.d("Img", "INFO_SUPPORTED_HARDWARE_LEVEL " + characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL));
     }
    

提交回复
热议问题