Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/window/OnBackInvokedCallback#pubmethods)

# OnBackInvokedCallback

*** ** * ** ***

` public interface OnBackInvokedCallback `   
` `

|---|
| android.window.OnBackInvokedCallback |

Known indirect subclasses [OnBackAnimationCallback](https://developer.android.com/reference/android/window/OnBackAnimationCallback) [OnBackAnimationCallback](https://developer.android.com/reference/android/window/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 `https://developer.android.com/reference/android/window/OnBackInvokedDispatcher`, which is held at window level and accessible through `https://developer.android.com/reference/android/app/Activity#getOnBackInvokedDispatcher()`, `https://developer.android.com/reference/android/app/Dialog#getOnBackInvokedDispatcher()`, `https://developer.android.com/reference/android/view/Window#getOnBackInvokedDispatcher()` and `https://developer.android.com/reference/android/view/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 `https://developer.android.com/reference/android/app/Activity#onBackPressed()`, `https://developer.android.com/reference/android/app/Dialog#onBackPressed()` and `https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_BACK`

If you want to customize back animation behaviors, in addition to handling back invocations, register its subclass instances `https://developer.android.com/reference/android/window/OnBackAnimationCallback` instead.

<br />

**See also:**

- `https://developer.android.com/reference/android/window/OnBackInvokedDispatcher#registerOnBackInvokedCallback(int,%20android.window.OnBackInvokedCallback)`

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/window/OnBackInvokedCallback#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](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onBackInvoked ()
```

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

<br />