public final class CameraSelector

A set of requirements and priorities used to select a camera or return a filtered set of cameras.

Summary

Constants

LENS_FACING_BACK

public static final int LENS_FACING_BACK = 1

A camera on the device facing the opposite direction as the device's screen.

LENS_FACING_EXTERNAL

@ExperimentalLensFacing
public static final int LENS_FACING_EXTERNAL = 2

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_FRONT

public static final int LENS_FACING_FRONT = 0

A camera on the device facing the same direction as the device's screen.

LENS_FACING_UNKNOWN

public static final int LENS_FACING_UNKNOWN = -1

A camera on the devices that its lens facing is resolved.

Public methods

filter

public @NonNull List<CameraInfofilter(@NonNull List<CameraInfo> cameraInfos)

Filters the input CameraInfos using the CameraFilters assigned to the selector.

If the CameraFilters assigned to this selector produce a camera info that is not part of the input list, the output list will be empty.

An example use case for using this function is when you want to get all CameraInfos for all available back facing cameras.

eg.

          
CameraInfo defaultBackCameraInfo = null;
CameraSelector selector = new CameraSelector.Builder()
     .requireLensFacing(LENS_FACING_BACK).build();
List<CameraInfo> cameraInfos = selector.filter(cameraProvider.getAvailableCameraInfos());

of

public static @NonNull CameraSelector of(@NonNull CameraIdentifier[] cameraIdentifiers)

Creates a CameraSelector that specifically targets the camera(s) represented by the given CameraIdentifiers.

When multiple identifiers are provided, they are treated as a prioritized list. CameraX will attempt to select and bind the camera for the first identifier. If that camera is not available, it will attempt to use the second, and so on.

Parameters
@NonNull CameraIdentifier[] cameraIdentifiers

A varargs array of one or more non-null CameraIdentifiers.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-10-22 UTC.