ProcessCameraProvider

public final class ProcessCameraProvider
extends Object implements CameraProvider

java.lang.Object
   ↳ androidx.camera.lifecycle.ProcessCameraProvider


A singleton which can be used to bind the lifecycle of cameras to any LifecycleOwner within an application's process.

Only a single process camera provider can exist within a process, and it can be retrieved with getInstance(Context).

Heavyweight resources, such as open and running camera devices, will be scoped to the lifecycle provided to bindToLifecycle(LifecycleOwner, CameraSelector, UseCase). Other lightweight resources, such as static camera characteristics, may be retrieved and cached upon first retrieval of this provider with getInstance(Context), and will persist for the lifetime of the process.

This is the standard provider for applications to use.

Summary

Public methods

Camera bindToLifecycle(LifecycleOwner lifecycleOwner, CameraSelector cameraSelector, UseCase... useCases)

Binds the collection of UseCase to a LifecycleOwner.

Camera bindToLifecycle(LifecycleOwner lifecycleOwner, CameraSelector cameraSelector, UseCaseGroup useCaseGroup)

Binds a UseCaseGroup to a LifecycleOwner.

static void configureInstance(CameraXConfig cameraXConfig)

Perform one-time configuration of the ProcessCameraProvider singleton with the given CameraXConfig.

List<CameraInfo> getAvailableCameraInfos()

Returns CameraInfo instances of the available cameras.

static ListenableFuture<ProcessCameraProvider> getInstance(Context context)

Retrieves the ProcessCameraProvider associated with the current process.

boolean hasCamera(CameraSelector cameraSelector)

Checks whether this provider supports at least one camera that meets the requirements from a CameraSelector.

boolean isBound(UseCase useCase)

Returns true if the UseCase is bound to a lifecycle.