Home » Android » api – Use rear facing dual camera in Android

api – Use rear facing dual camera in Android

Posted by: admin May 14, 2020 Leave a comment


I’m trying to capture using both of the rear facing cameras on my xiaomi mi 5s plus.
When I’m trying to iterate through the id’s of the cameras using camera2 api, I only get 2 id’s, one for the front facing camera and one for the rear one.
I’ve looked in the lg development examples (http://mobile.developer.lge.com/develop/sdks/lg-dual-camera/) and they are using 3 ids. When running their example, the app crashes.

The code used for getting the ids is:

CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
for(String id: manager.getCameraIdList())
    Log.e("test", id);
How to&Answers:

Capturing images from a dual camera is not natively supported before Android P. Android P now supports multi camera capture -> https://developer.android.com/preview/features#camera

Different vendors provide dual cameras for their Android devices in
hope to improve the photo quality for average user, more often than
not, specifically tuned for special conditions like challenging
illumination or distortions of selfie mode. Each vendor uses
proprietary technologies to handle dual cameras, and they are not
interested to disclose the implementation details. The only public
interface they support is a virtual single camera which is more or
less compliant with Google specs.

Courtesy of this Stack Overflow answer