# ProcessCameraProvider

Artifact: [androidx.camera:camera-lifecycle](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/lifecycle/ProcessCameraProvider.kt+class:androidx.camera.lifecycle.ProcessCameraProvider) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

*** ** * ** ***

<br />

```
public final class ProcessCameraProvider implements CameraProvider
```

<br />

*** ** * ** ***

A singleton which can be used to bind the lifecycle of cameras to any `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` within an application's process.

Only a single process camera provider can exist within a process, and it can be retrieved with `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)`.

Heavyweight resources, such as open and running camera devices, will be scoped to the lifecycle provided to `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(androidx.lifecycle.LifecycleOwner,androidx.camera.core.CameraSelector,kotlin.Array)`. Other lightweight resources, such as static camera characteristics, may be retrieved and cached upon first retrieval of this provider with `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)`, and will persist for the lifetime of the process.

This is the standard provider for applications to use.

## Summary

| ### Nested types |
|---|
| `public static class https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider.Companion` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#addCameraPresenceListener(java.util.concurrent.Executor,androidx.camera.core.CameraPresenceListener)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraPresenceListener listener )` Adds a listener for changes in camera presence. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera.SingleCameraConfig> singleCameraConfigs )` Binds list of `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera.SingleCameraConfig`s to `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/Camera` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(androidx.lifecycle.LifecycleOwner,androidx.camera.core.CameraSelector,androidx.camera.core.SessionConfig)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner lifecycleOwner, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/SessionConfig sessionConfig )` Binds a `https://developer.android.com/reference/androidx/camera/core/SessionConfig` to a `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/Camera` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(androidx.lifecycle.LifecycleOwner,androidx.camera.core.CameraSelector,androidx.camera.core.UseCaseGroup)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner lifecycleOwner, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/UseCaseGroup useCaseGroup )` Binds a `https://developer.android.com/reference/androidx/camera/core/UseCaseGroup` to a `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/Camera` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(androidx.lifecycle.LifecycleOwner,androidx.camera.core.CameraSelector,kotlin.Array)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner lifecycleOwner, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector, https://developer.android.com/reference/androidx/camera/core/UseCase... useCases )` Binds the collection of `https://developer.android.com/reference/androidx/camera/core/UseCase` to a `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`. |
| `static final void` | `@https://developer.android.com/reference/androidx/camera/lifecycle/ExperimentalCameraProviderConfiguration https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#configureInstance(androidx.camera.core.CameraXConfig)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraXConfig cameraXConfig)` Perform one-time configuration of the ProcessCameraProvider singleton with the given `https://developer.android.com/reference/androidx/camera/core/CameraXConfig`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraInfo>` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getAvailableCameraInfos()()` The `https://developer.android.com/reference/androidx/camera/core/CameraInfo` instances of the available cameras. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraInfo>>` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getAvailableConcurrentCameraInfos()()` Returns list of `https://developer.android.com/reference/androidx/camera/core/CameraInfo` instances of the available concurrent cameras. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraInfo` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getCameraInfo(androidx.camera.core.CameraSelector)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector)` Returns the `https://developer.android.com/reference/androidx/camera/core/CameraInfo` instance of the camera resulted from the specified `https://developer.android.com/reference/androidx/camera/core/CameraSelector`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraInfo` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getCameraInfo(androidx.camera.core.CameraSelector,androidx.camera.core.SessionConfig)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/SessionConfig sessionConfig )` Returns the `https://developer.android.com/reference/androidx/camera/core/CameraInfo` instance of the camera resulted from the specified `https://developer.android.com/reference/androidx/camera/core/CameraSelector` and `https://developer.android.com/reference/androidx/camera/core/SessionConfig`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider>` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context)` Retrieves the ProcessCameraProvider associated with the current process. |
| `boolean` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#hasCamera(androidx.camera.core.CameraSelector)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector)` Checks whether this provider supports at least one camera that meets the requirements from a `https://developer.android.com/reference/androidx/camera/core/CameraSelector`. |
| `final boolean` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#isBound(androidx.camera.core.SessionConfig)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/SessionConfig sessionConfig)` Returns `true` if the exact same instance of `https://developer.android.com/reference/androidx/camera/core/SessionConfig` is bound to a lifecycle, `false` otherwise. |
| `final boolean` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#isBound(androidx.camera.core.UseCase)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/UseCase useCase)` Returns `true` if this `https://developer.android.com/reference/androidx/camera/core/UseCase` is bound to a lifecycle or included in a bound `https://developer.android.com/reference/androidx/camera/core/SessionConfig`, `false` otherwise. |
| `boolean` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#isConcurrentCameraModeOn()()` Returns whether there is a `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera` bound. |
| `void` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#removeCameraPresenceListener(androidx.camera.core.CameraPresenceListener)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraPresenceListener listener)` Removes a previously registered camera presence listener. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Void.html>` | `@https://developer.android.com/reference/androidx/annotation/VisibleForTesting https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#shutdownAsync()()` Allows shutting down this ProcessCameraProvider instance so a new instance can be retrieved by `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)`. |
| `final void` | `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#unbind(androidx.camera.core.SessionConfig)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/SessionConfig sessionConfig)` Unbinds the specified `https://developer.android.com/reference/androidx/camera/core/SessionConfig` instance from the lifecycle provider. |
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#unbind(kotlin.Array)(https://developer.android.com/reference/androidx/camera/core/UseCase... useCases)` Unbinds all specified use cases from the lifecycle provider. |
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#unbindAll()()` Unbinds all use cases from the lifecycle provider and removes them from CameraX. |

## Public methods

### addCameraPresenceListener

```
public void addCameraPresenceListener(
    @NonNull Executor executor,
    @NonNull CameraPresenceListener listener
)
```

Adds a listener for changes in camera presence.

The listener will be notified when cameras are added to or removed from the set of devices that can be used by CameraX. This list of "usable" cameras has already been processed by any configured `https://developer.android.com/reference/androidx/camera/core/CameraSelector` limiters and compatibility filters.

**Important Note on Synchronization:** To prevent race conditions, this method immediately invokes `https://developer.android.com/reference/androidx/camera/core/CameraPresenceListener#onCamerasAdded(java.util.Set<androidx.camera.core.CameraIdentifier>)` **once** on the provided `https://developer.android.com/reference/androidx/camera/core/CameraProvider#addCameraPresenceListener(java.util.concurrent.Executor,androidx.camera.core.CameraPresenceListener)` with a `Set` containing all cameras that are currently available. This guarantees that the listener's state is synchronized with the provider's state at the moment of registration.

This listener reports on persistent hardware changes and does not fire for temporary, recoverable errors, such as when a camera is in use by another application.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` on which the listener's methods will be invoked. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraPresenceListener listener` | The listener to be added. |

### bindToLifecycle

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
@MainThread
public final @NonNull ConcurrentCamera bindToLifecycle(
    @NonNull List<ConcurrentCamera.SingleCameraConfig> singleCameraConfigs
)
```

Binds list of `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera.SingleCameraConfig`s to `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`.

This function only supports combinations that are available via `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#availableConcurrentCameraInfos()`. If the input list of `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera.SingleCameraConfig`s does not match any of the supported combinations returned by `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#availableConcurrentCameraInfos()`, `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown. If cameras are already used by other `https://developer.android.com/reference/androidx/camera/core/UseCase`s, `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` will be thrown.

To set up concurrent camera, call `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#availableConcurrentCameraInfos()` to get the list of available combinations of concurrent cameras. Each sub-list contains the `https://developer.android.com/reference/androidx/camera/core/CameraInfo`s for a combination of cameras that can be operated concurrently. Each camera can have its own `https://developer.android.com/reference/androidx/camera/core/UseCase`s and `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`. See {@docRoot}training/camerax/architecture#lifecycles

There are two modes:

1. Non-Composition mode: These `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera.SingleCameraConfig`s have different preview and video capture use cases and there is no `https://developer.android.com/reference/androidx/camera/core/CompositionSettings`. In this mode, these previews and video captures can stream separately. CameraX doesn't perform any composition. You can also bind an extra image capture along with the preview and the video capture use cases.

2. Composition mode: If the concurrent cameras are binding the same instances of preview and video capture use cases, the concurrent cameras video recording is supported. The concurrent camera preview stream will be shared with video capture and record the concurrent cameras streams as a composited stream. The `https://developer.android.com/reference/androidx/camera/core/CompositionSettings` can be used to configure the position of each camera stream and different layouts can be built. See `https://developer.android.com/reference/androidx/camera/core/CompositionSettings` for more details. The composition settings can also be updated dynamically by invoking `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera#setCompositionSettings(java.util.List<androidx.camera.core.CompositionSettings>)`. The composition mode only supports preview and video capture. ImageCapture is currently not supported. `https://developer.android.com/reference/androidx/camera/core/CameraEffect` can be applied on the composited stream. However, the mirrorMode of VideoCapture will be ignored. This means the recorded video will have the same mirrorMode as the preview.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera.SingleCameraConfig> singleCameraConfigs` | Input list of `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera.SingleCameraConfig`s. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera` | Output `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera` instance. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If the camera configs do not match any supported concurrent camera combination in `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#availableConcurrentCameraInfos()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | If device is not supporting concurrent camera or cameras are already used by other `https://developer.android.com/reference/androidx/camera/core/UseCase`s. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera` |   |
| `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#availableConcurrentCameraInfos()` |   |
| `https://developer.android.com/reference/androidx/camera/core/CameraInfo#isLogicalMultiCameraSupported()` |   |
| `https://developer.android.com/reference/androidx/camera/core/CameraInfo#getPhysicalCameraInfos()` |   |

### bindToLifecycle

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
public final @NonNull Camera bindToLifecycle(
    @NonNull LifecycleOwner lifecycleOwner,
    @NonNull CameraSelector cameraSelector,
    @NonNull SessionConfig sessionConfig
)
```

Binds a `https://developer.android.com/reference/androidx/camera/core/SessionConfig` to a `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`.

A `https://developer.android.com/reference/androidx/camera/core/SessionConfig` encapsulates the configuration required for a camera session. This includes:

- A collection of `https://developer.android.com/reference/androidx/camera/core/UseCase` instances defining the desired camera functionality.

- Session parameters to be applied to the camera.

- Common properties such as the field-of-view defined by `https://developer.android.com/reference/androidx/camera/core/ViewPort`.

- `https://developer.android.com/reference/androidx/camera/core/CameraEffect`s to be applied for image processing.

The state of the lifecycle will determine when the cameras are open, started, stopped and closed. When started, the use cases contained in the given `https://developer.android.com/reference/androidx/camera/core/SessionConfig` receive camera data and the parameters of `https://developer.android.com/reference/androidx/camera/core/SessionConfig` are used for configuring the camera including common field of view, effects and the session parameters.

Binding to a lifecycleOwner in state currently in `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#STARTED` or greater will also initialize and start data capture. If the camera was already running this may cause a new initialization to occur temporarily stopping data from the camera before restarting it.

Updates the `https://developer.android.com/reference/androidx/camera/core/SessionConfig` for a given `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` by invoking `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(androidx.lifecycle.LifecycleOwner,androidx.camera.core.CameraSelector,androidx.camera.core.SessionConfig)` again with the new `https://developer.android.com/reference/androidx/camera/core/SessionConfig`. There is no need to call `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#unbind(kotlin.Array)` or `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#unbindAll()`; the previous `https://developer.android.com/reference/androidx/camera/core/SessionConfig` and its associated `https://developer.android.com/reference/androidx/camera/core/UseCase`s will be implicitly unbound. This behavior also applies when rebinding to the same `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` with a different `https://developer.android.com/reference/androidx/camera/core/CameraSelector`, such as when switching the camera's lens facing.

**Important Restrictions:**

- You cannot bind a `https://developer.android.com/reference/androidx/camera/core/SessionConfig` to a `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` that already has individual `https://developer.android.com/reference/androidx/camera/core/UseCase`s or a `https://developer.android.com/reference/androidx/camera/core/UseCaseGroup` bound to it.

- A `https://developer.android.com/reference/androidx/camera/core/SessionConfig` bound to a `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` cannot contain `https://developer.android.com/reference/androidx/camera/core/UseCase`s that are already bound to a different `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`.

Violating these restrictions will result in an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html`.

The `https://developer.android.com/reference/androidx/camera/core/Camera` returned is determined by the given camera selector, plus other internal requirements, possibly from use case configurations. The camera returned from bindToLifecycle may differ from the camera determined solely by a camera selector. If the camera selector can't resolve a valid camera under the requirements, an IllegalArgumentException will be thrown.

The following code example shows various aspects of binding a session config.

```kotlin
import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageCapture
import androidx.camera.core.Preview
import androidx.camera.core.SessionConfig

val preview =
    Preview.Builder().build().also { it.surfaceProvider = previewView.surfaceProvider }
val imageCapture = ImageCapture.Builder().build()
val sessionConfig =
    SessionConfig(
        useCases = listOf(preview, imageCapture),
        viewPort = previewView.getViewPort(preview.getTargetRotation()),
        effects = listOf(effect1),
    )
// Starts the camera with the given effect and viewPort when the lifecycleOwner is started.
cameraProvider.bindToLifecycle(
    lifecycleOwner,
    CameraSelector.DEFAULT_BACK_CAMERA,
    sessionConfig,
)

// To apply a different effect, unbind the previous SessionConfig and bind the new SessionConfig
// with the new effect.
val sessionConfigNewEffect =
    SessionConfig(
        useCases = listOf(preview, imageCapture),
        viewPort = previewView.getViewPort(preview.getTargetRotation()),
        effects = listOf(effect2),
    )
// Make sures to unbind the previous sessionConfig before binding the new one
cameraProvider.unbind(sessionConfig)
cameraProvider.bindToLifecycle(
    lifecycleOwner,
    CameraSelector.DEFAULT_BACK_CAMERA,
    sessionConfigNewEffect,
)
```

The following code snippet demonstrates binding a session config with feature groups.

```kotlin
import androidx.camera.core.CameraSelector
import androidx.camera.core.SessionConfig
import androidx.camera.core.featuregroup.GroupableFeature.Companion.FPS_60
import androidx.camera.core.featuregroup.GroupableFeature.Companion.HDR_HLG10
import androidx.camera.core.featuregroup.GroupableFeature.Companion.PREVIEW_STABILIZATION

// Starts the camera with feature groups configured.
cameraProvider.bindToLifecycle(
    lifecycleOwner,
    CameraSelector.DEFAULT_BACK_CAMERA,
    // HDR is mandatory in this camera configuration and an exception will be thrown if it's not
    // supported. 60 FPS and preview stabilization are optional and used if they are also
    // supported, with the 60 FPS having higher priority over preview stabilization.
    SessionConfig(
            useCases = useCases,
            requiredFeatureGroup = setOf(HDR_HLG10),
            preferredFeatureGroup = listOf(FPS_60, PREVIEW_STABILIZATION),
        )
        .apply {
            setFeatureSelectionListener { features ->
                Log.d(
                    "TAG",
                    "Features selected as per priority and device capabilities: $features",
                )

                // Update app UI based on the selected features if required
            }
        },
)
```

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | If the camera is configured in concurrent mode. For example, if a list of `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera.SingleCameraConfig`s was bound to the lifecycle already. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if either of the following conditions is met: - A `https://developer.android.com/reference/androidx/camera/core/UseCase` or `https://developer.android.com/reference/androidx/camera/core/SessionConfig` is already bound to the same `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`. - A `https://developer.android.com/reference/androidx/camera/core/UseCase` contained within the `https://developer.android.com/reference/androidx/camera/core/SessionConfig` is already bound to a different `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`. |

### bindToLifecycle

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
@MainThread
public final @NonNull Camera bindToLifecycle(
    @NonNull LifecycleOwner lifecycleOwner,
    @NonNull CameraSelector cameraSelector,
    @NonNull UseCaseGroup useCaseGroup
)
```

Binds a `https://developer.android.com/reference/androidx/camera/core/UseCaseGroup` to a `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`.

Similar to `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(androidx.lifecycle.LifecycleOwner,androidx.camera.core.CameraSelector,androidx.camera.core.UseCaseGroup)`, with the addition that the bound collection of `https://developer.android.com/reference/androidx/camera/core/UseCase` share parameters defined by `https://developer.android.com/reference/androidx/camera/core/UseCaseGroup` such as consistent camera sensor rect across all `https://developer.android.com/reference/androidx/camera/core/UseCase`s.

If one `https://developer.android.com/reference/androidx/camera/core/UseCase` is in multiple `https://developer.android.com/reference/androidx/camera/core/UseCaseGroup`s, it will be linked to the `https://developer.android.com/reference/androidx/camera/core/UseCaseGroup` in the latest `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(androidx.lifecycle.LifecycleOwner,androidx.camera.core.CameraSelector,androidx.camera.core.UseCaseGroup)` call.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | If the camera is configured in concurrent mode. |

### bindToLifecycle

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
@MainThread
public final @NonNull Camera bindToLifecycle(
    @NonNull LifecycleOwner lifecycleOwner,
    @NonNull CameraSelector cameraSelector,
    UseCase... useCases
)
```

Binds the collection of `https://developer.android.com/reference/androidx/camera/core/UseCase` to a `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`.

The state of the lifecycle will determine when the cameras are open, started, stopped and closed. When started, the use cases receive camera data.

Binding to a lifecycleOwner in state currently in `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#STARTED` or greater will also initialize and start data capture. If the camera was already running this may cause a new initialization to occur temporarily stopping data from the camera before restarting it.

Multiple use cases can be bound via adding them all to a single bindToLifecycle call, or by using multiple bindToLifecycle calls. Using a single call that includes all the use cases helps to set up a camera session correctly for all uses cases, such as by allowing determination of resolutions depending on all the use cases bound being bound. If the use cases are bound separately, it will find the supported resolution with the priority depending on the binding sequence. If the use cases are bound with a single call, it will find the supported resolution with the priority in sequence of `https://developer.android.com/reference/androidx/camera/core/ImageCapture`, `https://developer.android.com/reference/androidx/camera/core/Preview` and then `https://developer.android.com/reference/androidx/camera/core/ImageAnalysis`. The resolutions that can be supported depends on the camera device hardware level that there are some default guaranteed resolutions listed in `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)`.

Currently up to 3 use cases may be bound to a `https://developer.android.com/reference/androidx/lifecycle/Lifecycle` at any time. Exceeding capability of target camera device will throw an IllegalArgumentException.

A UseCase should only be bound to a single lifecycle and camera selector a time. Attempting to bind a use case to a lifecycle when it is already bound to another lifecycle is an error, and the use case binding will not change. Attempting to bind the same use case to multiple camera selectors is also an error and will not change the binding.

Binding different use cases to the same lifecycle with different camera selectors that resolve to distinct cameras is an error, resulting in an exception.

The `https://developer.android.com/reference/androidx/camera/core/Camera` returned is determined by the given camera selector, plus other internal requirements, possibly from use case configurations. The camera returned from bindToLifecycle may differ from the camera determined solely by a camera selector. If the camera selector can't resolve a valid camera under the requirements, an IllegalArgumentException will be thrown.

Only `https://developer.android.com/reference/androidx/camera/core/UseCase` bound to latest active `https://developer.android.com/reference/androidx/lifecycle/Lifecycle` can keep alive. `https://developer.android.com/reference/androidx/camera/core/UseCase` bound to other `https://developer.android.com/reference/androidx/lifecycle/Lifecycle` will be stopped.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner lifecycleOwner` | The lifecycleOwner which controls the lifecycle transitions of the use cases. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector` | The camera selector which determines the camera to use for set of use cases. |
| `https://developer.android.com/reference/androidx/camera/core/UseCase... useCases` | The use cases to bind to a lifecycle. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/Camera` | The `https://developer.android.com/reference/androidx/camera/core/Camera` instance which is determined by the camera selector and internal requirements. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If the use case has already been bound to another lifecycle or method is not called on main thread. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If the provided camera selector is unable to resolve a camera to be used for the given use cases. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | If the camera is configured in concurrent mode. |

### configureInstance

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
@ExperimentalCameraProviderConfiguration
public static final void configureInstance(@NonNull CameraXConfig cameraXConfig)
```

Perform one-time configuration of the ProcessCameraProvider singleton with the given `https://developer.android.com/reference/androidx/camera/core/CameraXConfig`.

This method allows configuration of the camera provider via `https://developer.android.com/reference/androidx/camera/core/CameraXConfig`. All initialization tasks, such as communicating with the camera service, will be executed on the `https://developer.android.com/reference/java/util/concurrent/Executor.html` set by `https://developer.android.com/reference/androidx/camera/core/CameraXConfig.Builder#setCameraExecutor(java.util.concurrent.Executor)`, or by an internally defined executor if none is provided.

This method is not required for every application. If the method is not called and `https://developer.android.com/reference/androidx/camera/core/CameraXConfig.Provider` is not implemented in `https://developer.android.com/reference/android/app/Application.html`, default configuration will be used.

Once this method is called, the instance configured by the given `https://developer.android.com/reference/androidx/camera/core/CameraXConfig` can be retrieved with `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)`. `https://developer.android.com/reference/androidx/camera/core/CameraXConfig.Provider` implemented in `https://developer.android.com/reference/android/app/Application.html` will be ignored.

Configuration can only occur once. Once the ProcessCameraProvider has been configured with `configureInstance()` or `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)`, this method will throw an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html`. Because configuration can only occur once, **usage of this method from library code is not recommended** as the application owner should ultimately be in control of singleton configuration.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraXConfig cameraXConfig` | The configuration options for the singleton process camera provider instance. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If the camera provider has already been configured by a previous call to `configureInstance()` or `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)`. |

### getAvailableCameraInfos

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
public @NonNull List<@NonNull CameraInfo> getAvailableCameraInfos()
```

The `https://developer.android.com/reference/androidx/camera/core/CameraInfo` instances of the available cameras.

While iterating through all the available `https://developer.android.com/reference/androidx/camera/core/CameraInfo`, if one of them meets some predefined requirements, a `https://developer.android.com/reference/androidx/camera/core/CameraSelector` that uniquely identifies its camera can be retrieved using `https://developer.android.com/reference/androidx/camera/core/CameraInfo#getCameraSelector()`, which can then be used to bind `https://developer.android.com/reference/androidx/camera/core/UseCase` to that camera.

### getAvailableConcurrentCameraInfos

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
public @NonNull List<@NonNull List<@NonNull CameraInfo>> getAvailableConcurrentCameraInfos()
```

Returns list of `https://developer.android.com/reference/androidx/camera/core/CameraInfo` instances of the available concurrent cameras.

The available concurrent cameras include all combinations of cameras which could operate concurrently on the device. Each list maps to one combination of these camera's `https://developer.android.com/reference/androidx/camera/core/CameraInfo`.

For example, to select a front camera and a back camera and bind to `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` with preview `https://developer.android.com/reference/androidx/camera/core/UseCase`, this function could be used with `bindToLifecycle`.

```kotlin
import androidx.camera.core.CameraSelector
import androidx.camera.core.ConcurrentCamera.SingleCameraConfig
import androidx.camera.core.Preview
import androidx.camera.core.UseCaseGroup
import androidx.camera.view.PreviewView

var cameraSelectorPrimary: CameraSelector? = null
var cameraSelectorSecondary: CameraSelector? = null
for (cameraInfoList in cameraProvider.availableConcurrentCameraInfos) {
    for (cameraInfo in cameraInfoList) {
        if (cameraInfo.lensFacing == CameraSelector.LENS_FACING_FRONT) {
            cameraSelectorPrimary = cameraInfo.getCameraSelector()
        } else if (cameraInfo.lensFacing == CameraSelector.LENS_FACING_BACK) {
            cameraSelectorSecondary = cameraInfo.getCameraSelector()
        }
    }
}
if (cameraSelectorPrimary == null || cameraSelectorSecondary == null) {
    return
}
val previewFront = Preview.Builder().build()
previewFront.surfaceProvider = frontPreviewView.getSurfaceProvider()
val primary =
    SingleCameraConfig(
        cameraSelectorPrimary,
        UseCaseGroup.Builder().addUseCase(previewFront).build(),
        lifecycleOwner,
    )
val previewBack = Preview.Builder().build()
previewBack.surfaceProvider = backPreviewView.getSurfaceProvider()
val secondary =
    SingleCameraConfig(
        cameraSelectorSecondary,
        UseCaseGroup.Builder().addUseCase(previewBack).build(),
        lifecycleOwner,
    )
cameraProvider.bindToLifecycle(listOf(primary, secondary))
```

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraInfo>>` | List of combinations of `https://developer.android.com/reference/androidx/camera/core/CameraInfo`. |

### getCameraInfo

```
public @NonNull CameraInfo getCameraInfo(@NonNull CameraSelector cameraSelector)
```

Returns the `https://developer.android.com/reference/androidx/camera/core/CameraInfo` instance of the camera resulted from the specified `https://developer.android.com/reference/androidx/camera/core/CameraSelector`.

The returned `https://developer.android.com/reference/androidx/camera/core/CameraInfo` corresponds to the camera that will be bound when calling `bindToLifecycle` with the specified `https://developer.android.com/reference/androidx/camera/core/CameraSelector`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector` | the `https://developer.android.com/reference/androidx/camera/core/CameraSelector` to use for selecting the camera to receive information about. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraInfo` | the corresponding `https://developer.android.com/reference/androidx/camera/core/CameraInfo`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given `https://developer.android.com/reference/androidx/camera/core/CameraSelector` can't result in a valid camera to provide the `https://developer.android.com/reference/androidx/camera/core/CameraInfo`. |

### getCameraInfo

```
public @NonNull CameraInfo getCameraInfo(
    @NonNull CameraSelector cameraSelector,
    @NonNull SessionConfig sessionConfig
)
```

Returns the `https://developer.android.com/reference/androidx/camera/core/CameraInfo` instance of the camera resulted from the specified `https://developer.android.com/reference/androidx/camera/core/CameraSelector` and `https://developer.android.com/reference/androidx/camera/core/SessionConfig`.

The returned `https://developer.android.com/reference/androidx/camera/core/CameraInfo` corresponds to the camera that will be bound when calling `bindToLifecycle` with the specified `https://developer.android.com/reference/androidx/camera/core/CameraSelector` and `https://developer.android.com/reference/androidx/camera/core/SessionConfig`.

This method is used for the case when the input `https://developer.android.com/reference/androidx/camera/core/SessionConfig` can affect the camera selection or the information provided by the obtained CameraInfo object. For example, the `androidx.camera.extensions.ExtensionSessionConfig`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector` | the `https://developer.android.com/reference/androidx/camera/core/CameraSelector` to use for selecting the camera to receive information about. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/SessionConfig sessionConfig` | the `https://developer.android.com/reference/androidx/camera/core/SessionConfig` to use for selecting the camera to receive information about. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraInfo` | the corresponding `https://developer.android.com/reference/androidx/camera/core/CameraInfo`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given `https://developer.android.com/reference/androidx/camera/core/CameraSelector` and `https://developer.android.com/reference/androidx/camera/core/SessionConfig` can't result in a valid camera to provide the `https://developer.android.com/reference/androidx/camera/core/CameraInfo`. |

### getInstance

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
public static final @NonNull ListenableFuture<@NonNull ProcessCameraProvider> getInstance(@NonNull Context context)
```

Retrieves the ProcessCameraProvider associated with the current process.

The instance returned here can be used to bind use cases to any `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` with `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(androidx.lifecycle.LifecycleOwner,androidx.camera.core.CameraSelector,kotlin.Array)`.

The instance's configuration may be customized by subclassing the application's `https://developer.android.com/reference/android/app/Application.html` class and implementing `https://developer.android.com/reference/androidx/camera/core/CameraXConfig.Provider`. For example, the sample implements `https://developer.android.com/reference/androidx/camera/core/CameraXConfig.Provider#getCameraXConfig()` and initializes this process camera provider with a `https://developer.android.com/reference/androidx/camera/camera2/Camera2Config` from `https://developer.android.com/reference/androidx/camera/camera2/package-summary`, and with a custom executor.

```kotlin
import androidx.camera.camera2.Camera2Config
import androidx.camera.core.CameraXConfig

@Override
fun getCameraXConfig(): CameraXConfig {
    return CameraXConfig.Builder.fromConfig(Camera2Config.defaultConfig())
        .setCameraExecutor(executor)
        .setSchedulerHandler(handler)
        .build()
}
```

If it isn't possible to subclass the `https://developer.android.com/reference/android/app/Application.html` class, such as in library code, then the singleton can be configured via `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#configureInstance(androidx.camera.core.CameraXConfig)` before the first invocation of `getInstance(context)`, the sample implements a customized camera provider that configures the instance before getting it.

```kotlin
import androidx.camera.camera2.Camera2Config
import androidx.camera.core.CameraProvider
import androidx.camera.core.CameraXConfig
import androidx.camera.lifecycle.ExperimentalCameraProviderConfiguration
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.lifecycle.ProcessCameraProvider.Companion.configureInstance
import androidx.concurrent.futures.await

var configured = false // Whether the camera provider has been configured or not.

@androidx.annotation.OptIn(ExperimentalCameraProviderConfiguration::class)
suspend fun getInstance(context: Context): ProcessCameraProvider {
    synchronized(CameraProvider::class.java) {
        if (!configured) {
            configured = true
            configureInstance(
                CameraXConfig.Builder.fromConfig(Camera2Config.defaultConfig())
                    .setCameraExecutor(executor)
                    .setSchedulerHandler(scheduleHandler)
                    .build()
            )
        }
    }
    return ProcessCameraProvider.getInstance(context).await()
}
```

If no `https://developer.android.com/reference/androidx/camera/core/CameraXConfig.Provider` is implemented by `https://developer.android.com/reference/android/app/Application.html`, or if the singleton has not been configured via `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#configureInstance(androidx.camera.core.CameraXConfig)` a default configuration will be used.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | The application context. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider>` | A future which will contain the ProcessCameraProvider. Cancellation of this future is a no-op. This future may fail with an `https://developer.android.com/reference/androidx/camera/core/InitializationException` and associated cause that can be retrieved by `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/cause.html`. The cause will be a `https://developer.android.com/reference/androidx/camera/core/CameraUnavailableException` if it fails to access any camera during initialization. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if CameraX fails to initialize via a default provider or a `https://developer.android.com/reference/androidx/camera/core/CameraXConfig.Provider`. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#configureInstance(androidx.camera.core.CameraXConfig)` |   |

### hasCamera

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
public boolean hasCamera(@NonNull CameraSelector cameraSelector)
```

Checks whether this provider supports at least one camera that meets the requirements from a `https://developer.android.com/reference/androidx/camera/core/CameraSelector`.

If this method returns `true`, then the camera selector can be used to bind use cases and retrieve a `https://developer.android.com/reference/androidx/camera/core/Camera` instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraSelector cameraSelector` | the `https://developer.android.com/reference/androidx/camera/core/CameraSelector` that filters available cameras. |

| Returns |
|---|---|
| `boolean` | `true` if the device has at least one available camera, otherwise `false`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/camera/core/CameraInfoUnavailableException` | if unable to access cameras, perhaps due to insufficient permissions. |

### isBound

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
public final boolean isBound(@NonNull SessionConfig sessionConfig)
```

Returns `true` if the exact same instance of `https://developer.android.com/reference/androidx/camera/core/SessionConfig` is bound to a lifecycle, `false` otherwise.

After binding a `https://developer.android.com/reference/androidx/camera/core/SessionConfig`, this `https://developer.android.com/reference/androidx/camera/core/SessionConfig` remains bound until the lifecycle reaches a `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#DESTROYED` state or if is unbound by calls to `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#unbind(kotlin.Array)` or `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#unbindAll()`.

### isBound

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
public final boolean isBound(@NonNull UseCase useCase)
```

Returns `true` if this `https://developer.android.com/reference/androidx/camera/core/UseCase` is bound to a lifecycle or included in a bound `https://developer.android.com/reference/androidx/camera/core/SessionConfig`, `false` otherwise.

After binding a use case, use cases remain bound until the lifecycle reaches a `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#DESTROYED` state or if is unbound by calls to `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#unbind(kotlin.Array)` or `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#unbindAll()`.

### isConcurrentCameraModeOn

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
@MainThread
public boolean isConcurrentCameraModeOn()
```

Returns whether there is a `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera` bound.

| Returns |
|---|---|
| `boolean` | `true` if there is a `https://developer.android.com/reference/androidx/camera/core/ConcurrentCamera` bound, otherwise `false`. |

### removeCameraPresenceListener

```
public void removeCameraPresenceListener(@NonNull CameraPresenceListener listener)
```

Removes a previously registered camera presence listener.

Once removed, the listener will no longer receive updates. If the listener was not previously registered, this method is a no-op.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/CameraPresenceListener listener` | The same listener instance that was passed to `https://developer.android.com/reference/androidx/camera/core/CameraProvider#addCameraPresenceListener(java.util.concurrent.Executor,androidx.camera.core.CameraPresenceListener)`. |

### shutdownAsync

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
@VisibleForTesting
public final @NonNull ListenableFuture<@NonNull Void> shutdownAsync()
```

Allows shutting down this ProcessCameraProvider instance so a new instance can be retrieved by `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)`.

Once shutdownAsync is invoked, a new instance can be retrieved with `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)`.

This method should be used for testing purposes only. Along with `https://developer.android.com/reference/androidx/camera/lifecycle/ProcessCameraProvider#configureInstance(androidx.camera.core.CameraXConfig)`, this allows the process camera provider to be used in test suites which may need to initialize CameraX in different ways in between tests.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Void.html>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` representing the shutdown status. Cancellation of this future is a no-op. |

### unbind

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
public final void unbind(@NonNull SessionConfig sessionConfig)
```

Unbinds the specified `https://developer.android.com/reference/androidx/camera/core/SessionConfig` instance from the lifecycle provider.

This method will only unbind the session if the provided `sessionConfig` is the exact same instance that was previously used for binding.

This `https://developer.android.com/reference/androidx/camera/core/SessionConfig` contains the `https://developer.android.com/reference/androidx/camera/core/UseCase`s to be detached from the camera. This will initiate a close of every open camera which has zero `https://developer.android.com/reference/androidx/camera/core/UseCase` associated with it at the end of this call.

After unbinding the `https://developer.android.com/reference/androidx/camera/core/SessionConfig`, another `https://developer.android.com/reference/androidx/camera/core/SessionConfig` can be bound again and its `https://developer.android.com/reference/androidx/camera/core/UseCase`s can be bound to another `https://developer.android.com/reference/androidx/lifecycle/Lifecycle`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/SessionConfig sessionConfig` | The sessionConfig that contains the collection of use cases to remove. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If not called on main thread. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | If called in concurrent mode. |

### unbind

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
@MainThread
public final void unbind(UseCase... useCases)
```

Unbinds all specified use cases from the lifecycle provider.

This will initiate a close of every open camera which has zero `https://developer.android.com/reference/androidx/camera/core/UseCase` associated with it at the end of this call.

If a use case in the argument list is not bound, then it is simply ignored.

After unbinding a UseCase, the UseCase can be bound to another `https://developer.android.com/reference/androidx/lifecycle/Lifecycle` however listeners and settings should be reset by the application.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/camera/core/UseCase... useCases` | The collection of use cases to remove. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If not called on main thread. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | If called in concurrent mode. |

### unbindAll

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
@MainThread
public final void unbindAll()
```

Unbinds all use cases from the lifecycle provider and removes them from CameraX.

This will initiate a close of every currently open camera.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If not called on main thread. |