OnBackInvokedDispatcher
public
interface
OnBackInvokedDispatcher
android.window.OnBackInvokedDispatcher |
Dispatcher to register OnBackInvokedCallback
instances for handling
back invocations.
It also provides interfaces to update the attributes of OnBackInvokedCallback
.
Attribute updates are proactively pushed to the window manager if they change the dispatch
target (a.k.a. the callback to be invoked next), or its behavior.
Summary
Constants | |
---|---|
int |
PRIORITY_DEFAULT
Default priority level of |
int |
PRIORITY_OVERLAY
Priority level of |
Public methods | |
---|---|
abstract
void
|
registerOnBackInvokedCallback(int priority, OnBackInvokedCallback callback)
Registers a |
abstract
void
|
unregisterOnBackInvokedCallback(OnBackInvokedCallback callback)
Unregisters a |
Constants
PRIORITY_DEFAULT
public static final int PRIORITY_DEFAULT
Default priority level of OnBackInvokedCallback
s.
Constant Value: 0 (0x00000000)
PRIORITY_OVERLAY
public static final int PRIORITY_OVERLAY
Priority level of OnBackInvokedCallback
s for overlays such as menus and
navigation drawers that should receive back dispatch before non-overlays.
Constant Value: 1000000 (0x000f4240)
Public methods
registerOnBackInvokedCallback
public abstract void registerOnBackInvokedCallback (int priority, OnBackInvokedCallback callback)
Registers a OnBackInvokedCallback
.
Within the same priority level, callbacks are invoked in the reverse order in which
they are registered. Higher priority callbacks are invoked before lower priority ones.
Parameters | |
---|---|
priority |
int : The priority of the callback.
Value is PRIORITY_DEFAULT , or PRIORITY_OVERLAY
Value is 0 or greater |
callback |
OnBackInvokedCallback : The callback to be registered. If the callback instance has been already
registered, the existing instance (no matter its priority) will be
unregistered and registered again.
This value cannot be null . |
Throws | |
---|---|
|
java.lang.IllegalArgumentException IllegalArgumentException} if the priority is negative. |
unregisterOnBackInvokedCallback
public abstract void unregisterOnBackInvokedCallback (OnBackInvokedCallback callback)
Unregisters a OnBackInvokedCallback
.
Parameters | |
---|---|
callback |
OnBackInvokedCallback : The callback to be unregistered. Does nothing if the callback has not been
registered.
This value cannot be null . |