Stay organized with collections
Save and categorize content based on your preferences.
StateCallback
abstract class StateCallback
A callback object for receiving updates about the state of a camera extension session.
Summary
Public methods |
open Unit |
This method is called when the session is closed.
|
abstract Unit |
This method is called if the session cannot be configured as requested.
|
abstract Unit |
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
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()
was called). However, any in-progress capture requests submitted to the session will be completed as normal.
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: the session instance that failed to configure This value cannot be null . |
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
will be invoked instead of this callback.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# CameraExtensionSession.StateCallback\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nStateCallback\n=============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/hardware/camera2/CameraExtensionSession.StateCallback \"View this page in Java\") \n\n```\nabstract class StateCallback\n```\n\n|---|--------------------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.hardware.camera2.CameraExtensionSession.StateCallback](#) |\n\nA callback object for receiving updates about the state of a camera extension session.\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------|---|\n| [StateCallback](#StateCallback())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onClosed](#onClosed(android.hardware.camera2.CameraExtensionSession))`(`session:` `[CameraExtensionSession](/reference/kotlin/android/hardware/camera2/CameraExtensionSession)`)` This method is called when the session is closed. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onConfigureFailed](#onConfigureFailed(android.hardware.camera2.CameraExtensionSession))`(`session:` `[CameraExtensionSession](/reference/kotlin/android/hardware/camera2/CameraExtensionSession)`)` This method is called if the session cannot be configured as requested. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onConfigured](#onConfigured(android.hardware.camera2.CameraExtensionSession))`(`session:` `[CameraExtensionSession](/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. |\n\nPublic constructors\n-------------------\n\n### StateCallback\n\n```\nStateCallback()\n```\n\nPublic methods\n--------------\n\n### onClosed\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onClosed(session: CameraExtensionSession): Unit\n```\n\nThis method is called when the session is closed.\n\nA 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).\n\nOnce a session is closed, all methods on it will throw an IllegalStateException, and any repeating requests are stopped (as if [stopRepeating()](/reference/kotlin/android/hardware/camera2/CameraExtensionSession#stopRepeating()) was called). However, any in-progress capture requests submitted to the session will be completed as normal.\n\n| Parameters ||\n|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `session` | [CameraExtensionSession](/reference/kotlin/android/hardware/camera2/CameraExtensionSession): the session received during [StateCallback.onConfigured(CameraExtensionSession)](#onConfigured(android.hardware.camera2.CameraExtensionSession)) This value cannot be `null`. |\n\n### onConfigureFailed\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onConfigureFailed(session: CameraExtensionSession): Unit\n```\n\nThis method is called if the session cannot be configured as requested.\n\nThis 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.\n\nThe session is considered to be closed, and all methods called on it after this callback is invoked will throw an IllegalStateException.\n\n| Parameters ||\n|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `session` | [CameraExtensionSession](/reference/kotlin/android/hardware/camera2/CameraExtensionSession): the session instance that failed to configure This value cannot be `null`. |\n\n### onConfigured\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onConfigured(session: CameraExtensionSession): Unit\n```\n\nThis method is called when the camera device has finished configuring itself, and the session can start processing capture requests.\n\nIf the camera device configuration fails, then [onConfigureFailed](#onConfigureFailed(android.hardware.camera2.CameraExtensionSession)) will be invoked instead of this callback.\n\n| Parameters ||\n|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `session` | [CameraExtensionSession](/reference/kotlin/android/hardware/camera2/CameraExtensionSession): A valid extension session This value cannot be `null`. |"]]