OOmnistu

Blog / Engineering Playbooks

Engineering Playbooks

Android's Predictive Back Gesture, Explained: Opt-In Animations, OnBackPressedCallback, and the Migration Path

What predictive back shows, what changed in Android 15 (no more developer option), and how apps adopt it: AndroidX OnBackPressedCallback 1.6.0+, OnBackInvokedCallback, Compose's PredictiveBackHandler, and the opt-out flag.

OOmnistu
Reviewed 2026-11-20 · 2 min read

Predictive back is Android's gesture-navigation feature that lets users preview where a back swipe will take them - for example, an animated preview of the Home screen behind your app. Starting with Android 15, the developer option for these animations is gone: system animations such as back-to-home, cross-task and cross-activity simply appear for apps that have opted in to predictive back, entirely or at the activity level.

What supporting it means

Android's documentation defines support as updating your app to use the backward-compatible OnBackPressedCallback from AndroidX Activity 1.6.0 or higher, or the platform OnBackInvokedCallback API - and notes that most apps use the AndroidX API. The migration is really about back-event interception: you replace interceptions from KeyEvent.KEYCODE_BACK and any classes with onBackPressed methods, such as Activity and Dialog, with the new system Back APIs. One nuance the docs spell out: KeyEvent.KEYCODE_BACK itself is not deprecated - it still has supported use cases - but intercepting back events from it is no longer supported.

Compose has its own handler

For custom back gestures in Compose, the PredictiveBackHandler composable responds to the gesture and provides a Flow of BackEventCompat objects you can use to drive custom animations or transitions as the user swipes, including cancellation handling when the gesture is abandoned. It requires the androidx.activity:activity-compose dependency at version 1.8.0 or higher. If you only need to intercept the back gesture without tracking progress, the simpler BackHandler is enough.

Apps with default back navigation

If your app does not intercept back events, predictive back is enabled by default - the migration work is for interceptors. Apps using Fragments or the Navigation Component should also upgrade to AndroidX Activity 1.6.0 or higher.

Opting out

The android:enableOnBackInvokedCallback flag, set at app or activity level, lets you opt out: setting it to false turns off the predictive back animations and the system stops calling OnBackInvokedCallback. The docs note one behavior that surprises people: OnBackPressedCallback is always called regardless of the flag's value - it is backward compatible and calls the onBackPressed API, which is unsupported prior to Android 13.

Predictive back turns the back button into a preview surface. The work is concentrated in apps that intercept back events: move interception to OnBackPressedCallback or OnBackInvokedCallback, and the Android 15 animations follow.

Sources

Prepared with AI assistance and reviewed before publication. Android version scope, API names and the opt-out behavior are drawn from the Android documentation page above, checked on 20 November 2026.