# CameraExtensionSession.StateCallback

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# StateCallback

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/hardware/camera2/CameraExtensionSession.StateCallback "View this page in Java")  

```
abstract class StateCallback
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                                 ||
| ↳ | [android.hardware.camera2.CameraExtensionSession.StateCallback](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession.StateCallback#) |

A callback object for receiving updates about the state of a camera extension session.

## Summary

|                                                                     Public constructors                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [StateCallback](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession.StateCallback#StateCallback())`()` <br /> |

|                                                                                                                                                                                                                                                                         Public methods                                                                                                                                                                                                                                                                         ||
|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)     | [onClosed](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession.StateCallback#onClosed(android.hardware.camera2.CameraExtensionSession))`(`session:` `[CameraExtensionSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession)`)` This method is called when the session is closed.                                                                                            |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onConfigureFailed](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession.StateCallback#onConfigureFailed(android.hardware.camera2.CameraExtensionSession))`(`session:` `[CameraExtensionSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession)`)` This method is called if the session cannot be configured as requested.                                                    |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onConfigured](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession.StateCallback#onConfigured(android.hardware.camera2.CameraExtensionSession))`(`session:` `[CameraExtensionSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession)`)` This method is called when the camera device has finished configuring itself, and the session can start processing capture requests. |

## Public constructors

### StateCallback

```
StateCallback()
```

## Public methods

### onClosed

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onClosed(session: CameraExtensionSession): Unit
```

This method is called when the session is closed.

A session is closed when a new session is created by the parent camera device, or when the parent camera device is closed (either by the user closing the device, or due to a camera device disconnection or fatal error).

Once a session is closed, all methods on it will throw an IllegalStateException, and any repeating requests are stopped (as if[stopRepeating()](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession#stopRepeating())was called). However, any in-progress capture requests submitted to the session will be completed as normal.

|                                                                                                                                                                                                         Parameters                                                                                                                                                                                                         ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `session` | [CameraExtensionSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession):the session received during[StateCallback.onConfigured(CameraExtensionSession)](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession.StateCallback#onConfigured(android.hardware.camera2.CameraExtensionSession))This value cannot be`null`. |

### onConfigureFailed

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun onConfigureFailed(session: CameraExtensionSession): Unit
```

This method is called if the session cannot be configured as requested.

This can happen if the set of requested outputs contains unsupported sizes, too many outputs are requested at once or when trying to initialize multiple concurrent extension sessions from two (or more) separate camera devices or the camera device encounters an unrecoverable error during configuration.

The session is considered to be closed, and all methods called on it after this callback is invoked will throw an IllegalStateException.

|                                                                                                  Parameters                                                                                                   ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `session` | [CameraExtensionSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession):the session instance that failed to configure This value cannot be`null`. |

### onConfigured

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun onConfigured(session: CameraExtensionSession): Unit
```

This method is called when the camera device has finished configuring itself, and the session can start processing capture requests.

If the camera device configuration fails, then[onConfigureFailed](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession.StateCallback#onConfigureFailed(android.hardware.camera2.CameraExtensionSession))will be invoked instead of this callback.

|                                                                                        Parameters                                                                                         ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `session` | [CameraExtensionSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraExtensionSession):A valid extension session This value cannot be`null`. |