CameraSelector
CameraSelector
class is used to determine the requirements and priorities to select cameras.
Default CameraSelector
s​
There are some default CameraSelector
s that we can use out-of-the-box:
Default CameraSelector | Description |
---|---|
DEFAULT_BACK_CAMERA | A static CameraSelector that selects the default back facing camera. |
DEFAULT_FRONT_CAMERA | A static CameraSelector that selects the default front facing camera. |
Here's the equivalent of each constants:
// DEFAULT_BACK_CAMERA
public static final CameraSelector DEFAULT_BACK_CAMERA = new CameraSelector.Builder()
.requireLensFacing(LENS_FACING_BACK)
.build();
// DEFAULT_FRONT_CAMERA
public static final CameraSelector DEFAULT_FRONT_CAMERA = new CameraSelector.Builder()
.requireLensFacing(LENS_FACING_FRONT)
.build();
Lens Facing Types​
As you can see on the above section, CameraSelector
class contains some constants that represent the types of camera an app has based on its facing direction. There are 4 of these constants available:
Lens Facing Type | |
---|---|
LENS_FACING_FRONT | A camera on the device facing the same direction as the device's screen. |
LENS_FACING_BACK | A camera on the device facing the opposite direction as the device's screen. |
LENS_FACING_EXTERNAL | An external camera that has no fixed facing relative to the device's screen. The behavior of an external camera highly depends on the manufacturer. Currently it's treated similar to a front facing camera with little verification. So it's considered experimental and should be used with caution. |
LENS_FACING_UNKNOWN | A camera on the devices that its lens facing is resolved. |