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

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));
 }

Actually, checking for API version 21+ will work. The camera2 API, including CameraManager is part of the system, not dependent on the hardware present. So you can always ask the CameraManager for a list of CameraDevices, which you can then query individually.

However, I think what you actually mean is “how can I tell if I can set photographic parameters manually using the camera2 API?”, which is dependent on the device you have. It depends on what control you need, but the information you need can be gleaned by getting the REQUEST_AVAILABLE_CAPABILITIES metadata field. Hint: look for MANUAL_SENSOR.

I also needed this for another project, so I wrote a small app that probes all camera2 features and shows which ones are available on the phone: https://play.google.com/store/apps/details?id=de.weis.camera2probe

You can email this report in-app. I list all reports that I received here: https://github.com/TobiasWeis/android-camera2probe/wiki
(The code of the app is also available there, in case someone needs to integrate into their own project)

Leave a Comment