Stay organized with collections Save and categorize content based on your preferences.
Added in API level 33

OnBackInvokedCallback

public interface OnBackInvokedCallback

android.window.OnBackInvokedCallback


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() and Window#getOnBackInvokedDispatcher().

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 KeyEvent.KEYCODE_BACK

Summary

Public methods

abstract void onBackInvoked()

Called when a back gesture has been completed and committed, or back button pressed has been released and committed.

Public methods

onBackInvoked

Added in API level 33
public abstract void onBackInvoked ()

Called when a back gesture has been completed and committed, or back button pressed has been released and committed.