# CameraOfflineSession.CameraOfflineSessionCallback

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

# CameraOfflineSessionCallback

*** ** * ** ***

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

```
abstract class CameraOfflineSessionCallback
```

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

## Summary

|                                                                                                                                                                  Constants                                                                                                                                                                   ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [STATUS_INTERNAL_ERROR](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#STATUS_INTERNAL_ERROR:kotlin.Int) This status code indicates unexpected and fatal internal camera error. |

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

|                                                                                                                                                                                                                                                                                                                                                                                                             Public methods                                                                                                                                                                                                                                                                                                                                                                                                             ||
|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onClosed](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onClosed(android.hardware.camera2.CameraOfflineSession))`(`session:` `[CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession)`)` This method is called when the offline session is closed.                                                                                                                                                                                                                                                                                                                                                     |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onError](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onError(android.hardware.camera2.CameraOfflineSession,%20kotlin.Int))`(`session:` `[CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession)`, `status:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` This method is called when the offline session encounters an unexpected error.                                                                                                                                                                                                                            |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onIdle](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onIdle(android.hardware.camera2.CameraOfflineSession))`(`session:` `[CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession)`)` This method indicates that all pending offline requests were processed.                                                                                                                                                                                                                                                                                                                                           |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onReady](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onReady(android.hardware.camera2.CameraOfflineSession))`(`session:` `[CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession)`)` This method indicates that the offline switch call[CameraCaptureSession.switchToOffline](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraCaptureSession#switchToOffline(kotlin.collections.MutableCollection,%20java.util.concurrent.Executor,%20android.hardware.camera2.CameraOfflineSession.CameraOfflineSessionCallback))was successful.                                      |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSwitchFailed](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onSwitchFailed(android.hardware.camera2.CameraOfflineSession))`(`session:` `[CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession)`)` This method indicates that the offline switch call[CameraCaptureSession.switchToOffline](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraCaptureSession#switchToOffline(kotlin.collections.MutableCollection,%20java.util.concurrent.Executor,%20android.hardware.camera2.CameraOfflineSession.CameraOfflineSessionCallback))was not able to complete successfully. |

## Constants

### STATUS_INTERNAL_ERROR

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

```
static val STATUS_INTERNAL_ERROR: Int
```

This status code indicates unexpected and fatal internal camera error.

Pending offline requests will be discarded and the respective registered capture callbacks may not get triggered.  

    Value: 0

**See Also**

- [#onError](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onError(android.hardware.camera2.CameraOfflineSession,%20kotlin.Int))

## Public constructors

### CameraOfflineSessionCallback

```
CameraOfflineSessionCallback()
```

## Public methods

### onClosed

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

```
abstract fun onClosed(session: CameraOfflineSession): Unit
```

This method is called when the offline session is closed.

An offline session will be closed after a call to android.hardware.camera2.CameraOfflineSession#close.

In case of failure to switch to offline mode, only[onSwitchFailed](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onSwitchFailed(android.hardware.camera2.CameraOfflineSession))will be called and[onClosed](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onClosed(android.hardware.camera2.CameraOfflineSession))will not be.

In case there was no previous[onIdle](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onIdle(android.hardware.camera2.CameraOfflineSession))notification any in-progress offline capture requests within the offline session will be discarded and further result callbacks will not be triggered.

|                                                                                                                                                                                                                                         Parameters                                                                                                                                                                                                                                          ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `session` | [CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession):the session returned by[CameraCaptureSession.switchToOffline](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraCaptureSession#switchToOffline(kotlin.collections.MutableCollection,%20java.util.concurrent.Executor,%20android.hardware.camera2.CameraOfflineSession.CameraOfflineSessionCallback))This value cannot be`null`. |

### onError

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

```
abstract fun onError(
    session: CameraOfflineSession, 
    status: Int
): Unit
```

This method is called when the offline session encounters an unexpected error.

This notification will only be invoked for sessions that reached the ready state. Clients will need to call android.hardware.camera2.CameraOfflineSession#close to close and release all resources.[onClosed](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#onClosed(android.hardware.camera2.CameraOfflineSession))will not be triggered automatically in error scenarios.

|                                                                                                                                                                                Parameters                                                                                                                                                                                 ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `session` | [CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession):the current offline session This value cannot be`null`.                                                                                                                                                                                   |
| `status`  | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):error status Value is[android.hardware.camera2.CameraOfflineSession.CameraOfflineSessionCallback#STATUS_INTERNAL_ERROR](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession.CameraOfflineSessionCallback#STATUS_INTERNAL_ERROR:kotlin.Int) |

### onIdle

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

```
abstract fun onIdle(session: CameraOfflineSession): Unit
```

This method indicates that all pending offline requests were processed.

This callback will be invoked once the offline session finishes processing all of its pending offline capture requests.

|                                                                                           Parameters                                                                                            ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `session` | [CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession):the currently ready offline session This value cannot be`null`. |

### onReady

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

```
abstract fun onReady(session: CameraOfflineSession): Unit
```

This method indicates that the offline switch call[CameraCaptureSession.switchToOffline](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraCaptureSession#switchToOffline(kotlin.collections.MutableCollection,%20java.util.concurrent.Executor,%20android.hardware.camera2.CameraOfflineSession.CameraOfflineSessionCallback))was successful.

This callback will be invoked once the offline session moves to the ready state.

Calls to[CameraDevice.close](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraDevice#close())will not have impact on the processing of offline requests once the offline session moves in ready state.

|                                                                                           Parameters                                                                                            ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `session` | [CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession):the currently ready offline session This value cannot be`null`. |

### onSwitchFailed

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

```
abstract fun onSwitchFailed(session: CameraOfflineSession): Unit
```

This method indicates that the offline switch call[CameraCaptureSession.switchToOffline](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraCaptureSession#switchToOffline(kotlin.collections.MutableCollection,%20java.util.concurrent.Executor,%20android.hardware.camera2.CameraOfflineSession.CameraOfflineSessionCallback))was not able to complete successfully.

The offline switch can fail either due to internal camera error during the switch sequence or because the camera implementation was not able to find any pending capture requests that can be migrated to offline mode.

Calling android.hardware.camera2.CameraOfflineSession#close is not necessary and clients will not receive any further offline session notifications.

|                                                                                                      Parameters                                                                                                      ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `session` | [CameraOfflineSession](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraOfflineSession):the offline session that failed to switch to ready state This value cannot be`null`. |