Stay organized with collections
Save and categorize content based on your preferences.
OnBackInvokedCallback
interface OnBackInvokedCallback
Known Direct Subclasses
OnBackAnimationCallback |
Interface for applications to register back animation callbacks along their custom back handling.
|
|
Callback allowing applications to handle back events in place of the system.
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.
This replaces Activity#onBackPressed()
, Dialog#onBackPressed()
and android.view.KeyEvent#KEYCODE_BACK
If you want to customize back animation behaviors, in addition to handling back invocations, register its subclass instances OnBackAnimationCallback
instead.
Summary
Public methods |
abstract Unit |
Called when a back gesture has been completed and committed, or back button pressed has been released and committed.
|
Public methods
onBackInvoked
abstract fun onBackInvoked(): Unit
Called when a back gesture has been completed and committed, or back button pressed has been released and committed.
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 2024-04-04 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-04-04 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 2024-04-04 UTC."]]