CameraSelector.Builder

public final class CameraSelector.Builder


Builder for a CameraSelector.

Summary

Public constructors

Public methods

@NonNull CameraSelector.Builder

Adds a CameraFilter to the current set of filters.

@NonNull CameraSelector

Builds the CameraSelector.

@NonNull CameraSelector.Builder
requireLensFacing(int lensFacing)

Requires a camera with the specified lens facing.

Public constructors

Builder

Added in 1.0.0
public Builder()

Public methods

addCameraFilter

Added in 1.0.0
public @NonNull CameraSelector.Builder addCameraFilter(@NonNull CameraFilter cameraFilter)

Adds a CameraFilter to the current set of filters. It can be used to select a specific camera based on customized criteria like Camera2 characteristics.

Multiple filters can be added. All filters will be applied by the order they were added when the CameraSelector is used, and the first camera output from the filters will be selected.

Parameters
@NonNull CameraFilter cameraFilter

the CameraFilter for selecting cameras with.

Returns
@NonNull CameraSelector.Builder

this builder.

build

Added in 1.0.0
public @NonNull CameraSelector build()

Builds the CameraSelector.

requireLensFacing

Added in 1.0.0
public @NonNull CameraSelector.Builder requireLensFacing(int lensFacing)

Requires a camera with the specified lens facing.

Valid values for lens facing are LENS_FACING_FRONT, LENS_FACING_BACK and LENS_FACING_EXTERNAL. However, requiring LENS_FACING_EXTERNAL is currently experimental and may produce unexpected behaviors.

If lens facing is already set, this will add extra requirement for lens facing instead of replacing the previous setting.

Parameters
int lensFacing

the lens facing for selecting cameras with.

Returns
@NonNull CameraSelector.Builder

this builder.