Stay organized with collections
Save and categorize content based on your preferences.
OnBackAnimationCallback
public
interface
OnBackAnimationCallback
implements
OnBackInvokedCallback
android.window.OnBackAnimationCallback
|
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 |
default
void
|
onBackCancelled()
Called when a back gesture or back button press has been cancelled.
|
default
void
|
onBackProgressed(BackEvent backEvent)
Called when a back gesture progresses.
|
default
void
|
onBackStarted(BackEvent backEvent)
Called when a back gesture has been started, or back button has been pressed down.
|
Public methods
onBackCancelled
public void onBackCancelled ()
Called when a back gesture or back button press has been cancelled.
onBackProgressed
public void onBackProgressed (BackEvent backEvent)
Called when a back gesture progresses.
Parameters |
backEvent |
BackEvent : An BackEvent object describing the progress event.
This value cannot be null . |
onBackStarted
public void onBackStarted (BackEvent backEvent)
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# OnBackAnimationCallback\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nOnBackAnimationCallback\n=======================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/window/OnBackAnimationCallback \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nOnBackAnimationCallback\n`\n\n\n`\n\n\nimplements\n\n`[OnBackInvokedCallback](/reference/android/window/OnBackInvokedCallback)`\n\n\n`\n\n|----------------------------------------|\n| android.window.OnBackAnimationCallback |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nInterface for applications to register back animation callbacks along their custom back\nhandling.\n\n\nThis allows the client to customize various back behaviors by overriding the corresponding\ncallback methods.\n\n\nCallback instances can be added to and removed from [OnBackInvokedDispatcher](/reference/android/window/OnBackInvokedDispatcher), which\nis held at window level and accessible through [Activity.getOnBackInvokedDispatcher()](/reference/android/app/Activity#getOnBackInvokedDispatcher()),\n[Dialog.getOnBackInvokedDispatcher()](/reference/android/app/Dialog#getOnBackInvokedDispatcher()), [Window.getOnBackInvokedDispatcher()](/reference/android/view/Window#getOnBackInvokedDispatcher())\nand [View.findOnBackInvokedDispatcher()](/reference/android/view/View#findOnBackInvokedDispatcher()).\n\n\nWhen back is triggered, callbacks on the in-focus window are invoked in reverse order in which\nthey are added within the same priority. Between different priorities, callbacks with higher\npriority are invoked first.\n\n\u003cbr /\u003e\n\n**See also:**\n\n- [OnBackInvokedCallback](/reference/android/window/OnBackInvokedCallback)\n\nSummary\n-------\n\n| ### Public methods ||\n|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` default void` | ` `[onBackCancelled](/reference/android/window/OnBackAnimationCallback#onBackCancelled())`() ` Called when a back gesture or back button press has been cancelled. |\n| ` default void` | ` `[onBackProgressed](/reference/android/window/OnBackAnimationCallback#onBackProgressed(android.window.BackEvent))`(`[BackEvent](/reference/android/window/BackEvent)` backEvent) ` Called when a back gesture progresses. |\n| ` default void` | ` `[onBackStarted](/reference/android/window/OnBackAnimationCallback#onBackStarted(android.window.BackEvent))`(`[BackEvent](/reference/android/window/BackEvent)` backEvent) ` Called when a back gesture has been started, or back button has been pressed down. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[android.window.OnBackInvokedCallback](/reference/android/window/OnBackInvokedCallback)` ` |------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[onBackInvoked](/reference/android/window/OnBackInvokedCallback#onBackInvoked())`() ` Called when a back gesture has been completed and committed, or back button pressed has been released and committed. | ||\n\nPublic methods\n--------------\n\n### onBackCancelled\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void onBackCancelled ()\n```\n\nCalled when a back gesture or back button press has been cancelled.\n\n\u003cbr /\u003e\n\n### onBackProgressed\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void onBackProgressed (BackEvent backEvent)\n```\n\nCalled when a back gesture progresses.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| `backEvent` | `BackEvent`: An [BackEvent](/reference/android/window/BackEvent) object describing the progress event. This value cannot be `null`. \u003cbr /\u003e |\n\n**See also:**\n\n- [BackEvent](/reference/android/window/BackEvent) \n\n### onBackStarted\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void onBackStarted (BackEvent backEvent)\n```\n\nCalled when a back gesture has been started, or back button has been pressed down.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `backEvent` | `BackEvent`: The [BackEvent](/reference/android/window/BackEvent) containing information about the touch or button press. This value cannot be `null`. \u003cbr /\u003e |\n\n**See also:**\n\n- [BackEvent](/reference/android/window/BackEvent)"]]