fix: Hand the Android back button back to the platform - #145
Open
ecoreng wants to merge 1 commit into
Open
Conversation
`AppBootstrapActivity.onBackPressed()` discarded the return value of the back button listener and of `NavigationView.pop()`, both of which report whether the press was handled, and never called `super.onBackPressed()`. With no listener registered and a single view on the navigation stack, as in a freshly bootstrapped app, the press was swallowed and the activity could never be closed. Try the listener, then the navigation stack, then the platform default. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🎉 Bazel & CI Test Results
All Bazel configuration and CI tests passed! ✨ The build system and core tooling are working correctly. 🚀 Bazel remote cache is now enabled - future builds will be faster! Workflow: Valdi CI |
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.
Problem
On Android, the back button does nothing in a bootstrapped app — you can't get out of it.
AppBootstrapActivity.onBackPressed()calls a handler but ignores whether it handled the press, and never falls back tosuper.onBackPressed(). With no back handler registered and a single screen on the stack — a freshly bootstrapped app — the press is swallowed.Fix
Try each handler in turn, and give the press back to the platform if none took it:
falsewhen there's nothing to pop)super.onBackPressed()Note: a back handler returning
falsenow falls through to the navigation stack, where before it stopped there.Verified on a bootstrapped app built against
beta-0.1.1with this patch applied: back exits to the launcher, and still pops correctly with more than one screen.