# CameraDeviceInterop

Artifact: [androidx.camera:camera-camera2](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/camera2/interop/InteropBaseInterfaces.kt+class:androidx.camera.camera2.interop.CameraDeviceInterop) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
public interface CameraDeviceInterop
```

<br />

Known direct subclasses [SessionConfigCamera2Interop](https://developer.android.com/reference/androidx/camera/camera2/interop/SessionConfigCamera2Interop)

|---|---|
| `https://developer.android.com/reference/androidx/camera/camera2/interop/SessionConfigCamera2Interop` | Configures Camera2 options on a `https://developer.android.com/reference/androidx/camera/core/SessionConfig`. |

*** ** * ** ***

Configures Camera2 `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html` options.

## Summary

| ### Public methods |
|---|---|
| `abstract https://developer.android.com/reference/android/hardware/camera2/CameraDevice.StateCallback.html` | `https://developer.android.com/reference/androidx/camera/camera2/interop/CameraDeviceInterop#getDeviceStateCallback()()` The callback to receive camera device state updates on a direct executor. |
| `abstract void` | `https://developer.android.com/reference/androidx/camera/camera2/interop/CameraDeviceInterop#setDeviceStateCallback(android.hardware.camera2.CameraDevice.StateCallback)(https://developer.android.com/reference/android/hardware/camera2/CameraDevice.StateCallback.html value)` The callback to receive camera device state updates on a direct executor. |
| `abstract void` | `https://developer.android.com/reference/androidx/camera/camera2/interop/CameraDeviceInterop#setDeviceStateCallback(java.util.concurrent.Executor,android.hardware.camera2.CameraDevice.StateCallback)( @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/android/hardware/camera2/CameraDevice.StateCallback.html callback )` Sets the callback to receive camera device state updates with an executor. |

## Public methods

### getDeviceStateCallback

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

```
abstract CameraDevice.StateCallback getDeviceStateCallback()
```

The callback to receive camera device state updates on a direct executor.

**Warning:** The callback receives raw `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html` instances. Directly invoking state-altering, lifecycle, or session-creation methods on these raw objects bypasses CameraX pipeline management and causes state desynchronization, stream interruption, or crashes. Do not invoke:

- `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#close()`

- Session creation methods: `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)`, `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSessionByOutputConfigurations(java.util.List&lt;android.hardware.camera2.params.OutputConfiguration&gt;, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createReprocessableCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List&lt;android.view.Surface&gt;, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)`, or `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createExtensionSession(android.hardware.camera2.params.ExtensionSessionConfiguration)`

### setDeviceStateCallback

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

```
abstract void setDeviceStateCallback(CameraDevice.StateCallback value)
```

The callback to receive camera device state updates on a direct executor.

**Warning:** The callback receives raw `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html` instances. Directly invoking state-altering, lifecycle, or session-creation methods on these raw objects bypasses CameraX pipeline management and causes state desynchronization, stream interruption, or crashes. Do not invoke:

- `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#close()`

- Session creation methods: `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)`, `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSessionByOutputConfigurations(java.util.List&lt;android.hardware.camera2.params.OutputConfiguration&gt;, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createReprocessableCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List&lt;android.view.Surface&gt;, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)`, or `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createExtensionSession(android.hardware.camera2.params.ExtensionSessionConfiguration)`

### setDeviceStateCallback

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

```
abstract void setDeviceStateCallback(
    @NonNull Executor executor,
    @NonNull CameraDevice.StateCallback callback
)
```

Sets the callback to receive camera device state updates with an executor.

**Warning:** The `https://developer.android.com/reference/androidx/camera/camera2/interop/CameraDeviceInterop#setDeviceStateCallback(java.util.concurrent.Executor,android.hardware.camera2.CameraDevice.StateCallback)` receives raw `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html` instances. Directly invoking state-altering, lifecycle, or session-creation methods on these raw objects bypasses CameraX pipeline management and causes state desynchronization, stream interruption, or crashes. Do not invoke:

- `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#close()`

- Session creation methods: `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)`, `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSessionByOutputConfigurations(java.util.List&lt;android.hardware.camera2.params.OutputConfiguration&gt;, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createReprocessableCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List&lt;android.view.Surface&gt;, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)`, or `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createExtensionSession(android.hardware.camera2.params.ExtensionSessionConfiguration)`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | executor to run the callback on |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/camera2/CameraDevice.StateCallback.html callback` | device state callback |