---
title: "Handle the back gesture with the · Agent Wranglers"
url: https://agentwranglers.se/playbook/mobile-apps/updates-and-versions/predictive-back
id: MOB-55
level: Recommended
updated: 2026-10-27
build: a2a6bdfed830
tokens: 996
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Handle the back gesture with the predictive back callbacks

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Updates and versions](https://agentwranglers.se/playbook/mobile-apps/updates-and-versions.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: MOB-55
- Level: Recommended
- Chapter: [Updates and versions](https://agentwranglers.se/playbook/mobile-apps/updates-and-versions.md)
- Rule: Android code that changes what back does registers an `OnBackPressedCallback` or `OnBackInvokedCallback`. No code overrides `onBackPressed` or listens for `KEYCODE_BACK`.
- Check: A search of the source finds no `onBackPressed` override and no `KEYCODE_BACK` handler. A UI test on an Android 16 emulator opens a sheet, swipes back and finds the sheet closed with the screen still open.
- Review by: 2027-08-31
- How: For apps that target Android 16 on Android 16 devices, the system no longer calls `onBackPressed` and no longer sends `KEYCODE_BACK`. Code that saved a draft or closed a sheet there stops running, and back simply leaves the screen. The predictive back animations are also on by default for those apps. Register a callback that is enabled only while there is something to undo, such as an open sheet or an unsaved form. Setting `android:enableOnBackInvokedCallback="false"` turns the new behaviour off for now, but Google calls that opt-out temporary. The new behaviour starts when the target moves, as [build with the SDK the stores require](https://agentwranglers.se/playbook/mobile-apps/updates-and-versions/store-sdk-deadlines.md) describes.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Kotlin example

```kotlin
private val closeSheetOnBack = object : OnBackPressedCallback(false) {
    override fun handleOnBackPressed() = sheet.close()
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    onBackPressedDispatcher.addCallback(this, closeSheetOnBack)
    sheet.onOpenChanged { isOpen -> closeSheetOnBack.isEnabled = isOpen }
}
```

### Java example

```java
private final OnBackPressedCallback closeSheetOnBack = new OnBackPressedCallback(false) {
    @Override public void handleOnBackPressed() { sheet.close(); }
};

@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getOnBackPressedDispatcher().addCallback(this, closeSheetOnBack);
    sheet.setOnOpenChanged(isOpen -> closeSheetOnBack.setEnabled(isOpen));
}
```

## Sources

- [Android 16 behavior changes, predictive back](https://developer.android.com/about/versions/16/behavior-changes-16)
- [Android, Add support for predictive back](https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture)

## Related rules

- MOB-15 [Build with the SDK the stores require](https://agentwranglers.se/playbook/mobile-apps/updates-and-versions/store-sdk-deadlines.md) in Mobile apps

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/mobile-apps/updates-and-versions/predictive-back">Agent Wranglers mobile apps playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Draw edge to edge and pad content by the system insets](https://agentwranglers.se/playbook/mobile-apps/updates-and-versions/edge-to-edge-insets.md)
- Next: [Lay out every screen for tablets and foldables in both orientations](https://agentwranglers.se/playbook/mobile-apps/updates-and-versions/large-screen-layouts.md)
- [Updates and versions](https://agentwranglers.se/playbook/mobile-apps/updates-and-versions.md)
