Support Android 13's predictive back gesture #276
Merged
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.
This allows the library's navigation to respect Android 13/14's new predictive back gesture. Documentation: https://developer.android.com/guide/navigation/predictive-back-gesture
This disable the
Activity
'sOnBackPressedCallback
when the current nav controller is at its start destination. This allows the system to take control over the back behavior when leaving the app and display a custom animation.Even if a particular user doesn't not have the "Preditive back animations" Developer Option enabled in Android 13, this change still provides a tangible benefit. The app's main Activity will no longer
.finish()
when using the back gesture/button to leave the app. For the first time, Android 13 maintains theActivity
instance if an app does not manually call.finish()
.On Android 13, apps that want to opt into the predictive back gesture must enable the following
AndroidManifest
flag:Note that Android 14 will further expand on the predictive back gesture including between screens, but the
AndroidX
APIs are not finalized and it requires targeting SDK34
, which hasn't hit API stability yet.