MBL-2704 Support predictive back for Android 16 #2407
Merged
+2
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📲 What
Properly intercept back navigation, which involves replacing back interceptions from KeyEvent.KEYCODE_BACK and any classes with onBackPressed methods such as Activity and Dialog with the new system Back APIs.
🤔 Why
Support predictive back for Android 16: https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back
🛠 How
Most of our app was already using the backward compatible OnBackPressedCallback API. All I did was remove a couple of places where we were calling the deprecated onBackPressed().
👀 See
Note! You'll need to set compilesdk and targetsdk = 36 in build.gradle(app) because predictive back animation is set by default in Android 16.
Compare back-to-home animations of Chrome (opted-in), Kickstarter (opted-in), and Slack (not targeting api 36 yet so not opted-in)
Screen_recording_20250819_111022.mp4
📋 QA
Set compilesdk and targetsdk = 36 in build.gradle(app).
Open the app, and swipe back to view the back-to-home animation.
Story 📖
https://kickstarter.atlassian.net/browse/MBL-2704