SystemOnBackInvokedCallbacks
public
final
class
SystemOnBackInvokedCallbacks
extends Object
java.lang.Object | |
↳ | android.window.SystemOnBackInvokedCallbacks |
Utility class providing OnBackInvokedCallback
s to override the default behavior when
system back is invoked. e.g. Activity.finish
By registering these callbacks with the OnBackInvokedDispatcher
, the system can
trigger specific behaviors and play corresponding ahead-of-time animations when the back
gesture is invoked.
For example, to trigger the Activity.moveTaskToBack
behavior:
OnBackInvokedDispatcher dispatcher = activity.getOnBackInvokedDispatcher(); dispatcher.registerOnBackInvokedCallback( OnBackInvokedDispatcher.PRIORITY_DEFAULT, SystemOnBackInvokedCallbacks.moveTaskToBackCallback(activity));
Summary
Public methods | |
---|---|
static
OnBackInvokedCallback
|
finishAndRemoveTaskCallback(Activity activity)
Get a callback to triggers |
static
OnBackInvokedCallback
|
moveTaskToBackCallback(Activity activity)
Get a callback to triggers |
Inherited methods | |
---|---|
Public methods
finishAndRemoveTaskCallback
public static OnBackInvokedCallback finishAndRemoveTaskCallback (Activity activity)
Get a callback to triggers Activity.finishAndRemoveTask()
on the associated
Activity
. If the activity is the root activity of its task, the entire task
will be removed from the recents task. The activity will be finished in all cases.
The system will play the corresponding transition animation.
Parameters | |
---|---|
activity |
Activity : The associated Activity
This value cannot be null . |
Returns | |
---|---|
OnBackInvokedCallback |
This value cannot be null . |
See also:
moveTaskToBackCallback
public static OnBackInvokedCallback moveTaskToBackCallback (Activity activity)
Get a callback to triggers Activity.moveTaskToBack(boolean)
on the associated
Activity
, moving the task containing the activity to the background. The system
will play the corresponding transition animation, regardless of whether the activity
is the root activity of the task.
Parameters | |
---|---|
activity |
Activity : The associated Activity
This value cannot be null . |
Returns | |
---|---|
OnBackInvokedCallback |
This value cannot be null . |
See also: