I have a app that uses the Camera2 API to get a preview of the camera. I want to choose between the lens of my phone. In my code I am using the following code:
CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
String[] ids = manager.getCameraIdList();
When I use my galaxy s10 that have 2 front facing cameras (regular and wide) and 3 rear facing cameras I only get 4 ids back from the manager:
0- regular rear
1- regular front
2- wide rear
3- wide front
why I don't get the 3 rear macro camera.
the problems appear in all of my phones that have more then 1 camera facing back
how can I get all of the rear cameras?
tnx ahead
As per the documentation you are getting only the logical cameras.
public String[] getCameraIdList ()
Return the list of currently connected camera devices by identifier, including cameras that may be in use by other camera API clients.
Non-removable cameras use integers starting at 0 for their identifiers, while removable cameras have a unique identifier for each individual device, even if they are the same model.
This list doesn't contain physical cameras that can only be used as part of a logical multi-camera device.
Returns
String[] The list of currently connected camera devices. This value cannot be null.
To get the physical cameras, use this

REFERENCES:
https://source.android.com/devices/camera/multi-camera
Camera2 replacing one logical stream with two physical streams in Android API 29
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With