A Developer’s Roadmap to Predictive Back (Views)
The first milestone is to upgrade to Kotlin 1.8.0 or higher, which is required for other Predictive Back dependencies.
Back-to-home animation milestone
The back-to-home animation is the keystone predictive back animation.
To get this animation, add android:enableOnBackInvokedCallback=true
in your AndroidManifest.xml
for your root activity if you are a multi-activity app (see per-activity opt-in) or at the application level if you are a single-activity app. After this, you’ll see both the back-to-home animation and a cross-task animation where applicable, which are visible to users in Android 15+ and behind a developer option in Android 13 and 14.
If you are intercepting back events in your root activity (e.g. MainActivity), you can continue to do so but you’ll need to use supported APIs and you won’t get the back-to-home animation. For this reason, we generally recommend you only intercept back events for UI logic; for example, to show a dialog asking the user to save before they quit.
See the Add support for the predictive back gesture guide for more details.
Migrate all activities milestone
If you are a multi-activity app, you’ll need to opt-in and handle back events within those activities too to get a system controlled cross-activity animation. Learn more about per-activity opt-in, available for devices running Android 14+. The cross-activity animation is visible to users in Android 15+ and behind a developer option in Android 13 and 14.
Custom cross activity animations are also available with overrideActivityTransition.
Fragment milestone
Next, you’ll want to focus on your fragment animations and transitions. This requires updating to AndroidX fragment 1.7.0 and transition 1.5.0 or later and using Animator or AndroidX Transitions. Assuming these requirements are met, your existing fragment animations and transitions will animate in step with the back gesture. You can also use material motion with fragments. Most material motions support predictive back as of 1.12.02-alpha02 or higher, including MaterialFadeThrough, MaterialSharedAxis and MaterialFade.
Don’t strive to make your fragment transitions look like the system’s cross-activity transition. We recommend this full screen surface transition instead.
Learn more about Fragments and Predictive Back.
Material Components milestone
Finally, you’ll want to take advantage of the Material Component View animations available for Predictive Back. Learn more about available components.
After this, you’ve completed your quest to support Predictive Back animations in your view based app.
[Optional] AndroidX Transitions milestone
If you’re up for more, you might also ensure your AndroidX transitions are supported with Predictive Back. Read more about AndroidX Transitions and the Predictive Back Progress APIs.