Stay organized with collections
Save and categorize content based on your preferences.
OnBackAnimationCallback
interface OnBackAnimationCallback : OnBackInvokedCallback
Interface for applications to register back animation callbacks along their custom back handling.
This allows the client to customize various back behaviors by overriding the corresponding callback methods.
Callback instances can be added to and removed from OnBackInvokedDispatcher
, which is held at window level and accessible through Activity.getOnBackInvokedDispatcher()
, Dialog.getOnBackInvokedDispatcher()
, Window.getOnBackInvokedDispatcher()
and View.findOnBackInvokedDispatcher()
.
When back is triggered, callbacks on the in-focus window are invoked in reverse order in which they are added within the same priority. Between different priorities, callbacks with higher priority are invoked first.
Summary
Public methods |
open Unit |
Called when a back gesture or back button press has been cancelled.
|
open Unit |
Called when a back gesture progresses.
|
open Unit |
Called when a back gesture has been started, or back button has been pressed down.
|
Public methods
onBackCancelled
open fun onBackCancelled(): Unit
Called when a back gesture or back button press has been cancelled.
onBackProgressed
open fun onBackProgressed(backEvent: BackEvent): Unit
Called when a back gesture progresses.
Parameters |
backEvent |
BackEvent: An BackEvent object describing the progress event. This value cannot be null . |
onBackStarted
open fun onBackStarted(backEvent: BackEvent): Unit
Called when a back gesture has been started, or back button has been pressed down.
Parameters |
backEvent |
BackEvent: The BackEvent containing information about the touch or button press. This value cannot be null . |
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,["# OnBackAnimationCallback\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnBackAnimationCallback\n=======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/window/OnBackAnimationCallback \"View this page in Java\") \n\n```\ninterface OnBackAnimationCallback : OnBackInvokedCallback\n```\n\n|---------------------------------------------|\n| [android.window.OnBackAnimationCallback](#) |\n\nInterface for applications to register back animation callbacks along their custom back handling.\n\nThis allows the client to customize various back behaviors by overriding the corresponding callback methods.\n\nCallback instances can be added to and removed from [OnBackInvokedDispatcher](/reference/kotlin/android/window/OnBackInvokedDispatcher), which is held at window level and accessible through [Activity.getOnBackInvokedDispatcher()](../app/Activity.html#getOnBackInvokedDispatcher()), [Dialog.getOnBackInvokedDispatcher()](../app/Dialog.html#getOnBackInvokedDispatcher()), [Window.getOnBackInvokedDispatcher()](../view/Window.html#getOnBackInvokedDispatcher()) and [View.findOnBackInvokedDispatcher()](../view/View.html#findOnBackInvokedDispatcher()).\n\nWhen back is triggered, callbacks on the in-focus window are invoked in reverse order in which they are added within the same priority. Between different priorities, callbacks with higher priority are invoked first.\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onBackCancelled](#onBackCancelled())`()` Called when a back gesture or back button press has been cancelled. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onBackProgressed](#onBackProgressed(android.window.BackEvent))`(`backEvent:` `[BackEvent](/reference/kotlin/android/window/BackEvent)`)` Called when a back gesture progresses. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onBackStarted](#onBackStarted(android.window.BackEvent))`(`backEvent:` `[BackEvent](/reference/kotlin/android/window/BackEvent)`)` Called when a back gesture has been started, or back button has been pressed down. |\n\n| Inherited functions ||\n|---|---|\n| From class [OnBackInvokedCallback](/reference/kotlin/android/window/OnBackInvokedCallback) |------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onBackInvoked](/reference/kotlin/android/window/OnBackInvokedCallback#onBackInvoked())`()` Called when a back gesture has been completed and committed, or back button pressed has been released and committed. \u003cbr /\u003e | ||\n\nPublic methods\n--------------\n\n### onBackCancelled\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onBackCancelled(): Unit\n```\n\nCalled when a back gesture or back button press has been cancelled. \n\n### onBackProgressed\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onBackProgressed(backEvent: BackEvent): Unit\n```\n\nCalled when a back gesture progresses.\n\n| Parameters ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `backEvent` | [BackEvent](/reference/kotlin/android/window/BackEvent): An [BackEvent](/reference/kotlin/android/window/BackEvent) object describing the progress event. This value cannot be `null`. |\n\n**See Also**\n\n- [android.window.BackEvent](/reference/kotlin/android/window/BackEvent) \n\n### onBackStarted\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onBackStarted(backEvent: BackEvent): Unit\n```\n\nCalled when a back gesture has been started, or back button has been pressed down.\n\n| Parameters ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `backEvent` | [BackEvent](/reference/kotlin/android/window/BackEvent): The [BackEvent](/reference/kotlin/android/window/BackEvent) containing information about the touch or button press. This value cannot be `null`. |\n\n**See Also**\n\n- [android.window.BackEvent](/reference/kotlin/android/window/BackEvent)"]]