Repository navigation
fix: restore in-app back navigation under predictive back - #628
Merged
Merged
Conversation
fortuna
added this pull request to stack #624
September 15, 2026 18:06
peterwgnd
force-pushed
the
build/remove-legacy-agp-flags
branch
from
September 15, 2026 18:17
b05742a to
dca8589
Compare
peterwgnd
force-pushed
the
fix/predictive-back
branch
from
September 15, 2026 18:17
ff2c84e to
1d9054e
Compare
fortuna
removed this pull request from stack #624
September 15, 2026 18:21
fortuna
force-pushed
the
fix/predictive-back
branch
from
September 15, 2026 18:22
1d9054e to
fdeed0f
Compare
fortuna
changed the base branch from
build/remove-legacy-agp-flags
to
master
September 15, 2026 18:22
fortuna
force-pushed
the
fix/predictive-back
branch
from
September 15, 2026 18:41
fdeed0f to
d802521
Compare
MainActivity overrode onBackPressed() to return to the home view from the settings and info screens. Apps targeting SDK 36 can no longer opt out of predictive back, and the platform now routes back gestures through OnBackPressedDispatcher instead of calling onBackPressed(), so back was leaving the app instead of returning home. Lint flags this as GestureBackNavigation, and only at targetSdk 36 -- the bump in #623 is what introduced the regression. Replace the override with an OnBackPressedCallback registered on the dispatcher. The callback is enabled only while a non-home view is showing, mirroring the existing up-arrow logic in chooseView(), so back still exits the app from the home view. isShowingHomeView() is now unused and removed. This needs androidx.activity 1.6+ to bridge the platform callback; the pinned appcompat 1.4.0 only brings in activity 1.2.4. Upgrade appcompat to 1.7.1, which pulls activity 1.8.0 and still supports minSdk 21. Deliberately not 1.8.0, which would require raising minSdk to 23.
fortuna
force-pushed
the
fix/predictive-back
branch
from
September 15, 2026 18:43
d802521 to
bd66ebc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes in-app back navigation, which is broken on
masterright now, and resolves theGestureBackNavigationlint error.Important
This is a follow-up to #623 (already merged). That PR bumped
targetSdkto 36, which iswhat introduced this regression. This PR is based directly on
masterand isindependent of the AGP stack (#625/#626/#627), so it can merge on its own.
The bug
MainActivityoverrodeonBackPressed()so that back returns to the home view from thesettings and info screens:
Apps targeting SDK 36 can no longer opt out of predictive back, and the platform
routes back gestures through
OnBackPressedDispatcherinstead of callingonBackPressed(). So pressing back from Settings exits the app rather than returningto the home view.
This is specific to
targetSdk36 — it is not a pre-existing bug. RunninglintDebugacross
targetSdkvalues on an otherwise identical tree:GestureBackNavigationtargetSdk 35 (Android 15) turned on predictive back animations but kept the legacy
onBackPressed()path working. targetSdk 36 (Android 16) removes that compatibility path.The fix
Register an
OnBackPressedCallbackon the dispatcher instead, enabled only while anon-home view is showing:
chooseView()is the single funnel for every view change, so it is the natural place tokeep the enabled state in sync. It sits right next to the existing up-arrow logic, which
already encodes the same "am I on the home view" condition:
When disabled, back falls through to the system and leaves the app, preserving the
original behavior.
isShowingHomeView()has no remaining callers and is removed.Why AppCompat moves 1.4.0 -> 1.7.1
Bridging the platform's
OnBackInvokedCallbackintoOnBackPressedDispatcherneedsandroidx.activity1.6+. The pinned appcompat 1.4.0 resolvedactivity:1.2.4, whichpredates predictive back entirely. appcompat 1.7.1 pulls
activity:1.8.0.Note
appcompat 1.8.0 is newer, but requires raising
minSdkto 23:1.7.1 is used deliberately so that
minSdkstays at 21 and Android 5.x users are notdropped. For a censorship-circumvention tool, old devices are worth keeping.
gradle/verification-metadata.xmlis updated with the new transitive dependencies(activity 1.8.0, lifecycle 2.6.x, core 1.13.0, emoji2, savedstate, profileinstaller, ...).
Verification
./gradlew clean assembleDebug testpasses.GestureBackNavigationis gone. The remaining lint errors are the 3 pre-existing ones(
StartActivityAndCollapseDeprecated,RestrictedApi,QueryAllPackagesPermission).Exercised on a Pixel 8 emulator running API 36 (the configuration where the bug
reproduces), driving the UI over
adb+uiautomator:Both
chooseView()entry points are covered: the settings view and the info view. Backfrom the home view still exits, so the pre-existing behavior is preserved.