Skip to content

fix: Hand the Android back button back to the platform - #145

Open
ecoreng wants to merge 1 commit into
Snapchat:mainfrom
ecoreng:fix/android-back-button
Open

fix: Hand the Android back button back to the platform#145
ecoreng wants to merge 1 commit into
Snapchat:mainfrom
ecoreng:fix/android-back-button

Conversation

@ecoreng

@ecoreng ecoreng commented Aug 12, 2026

Copy link
Copy Markdown

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 to super.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:

  1. the component's back handler (returns whether it handled the press)
  2. the navigation stack pop (returns false when there's nothing to pop)
  3. super.onBackPressed()

Note: a back handler returning false now falls through to the navigation stack, where before it stopped there.

Verified on a bootstrapped app built against beta-0.1.1 with this patch applied: back exits to the launcher, and still pops correctly with more than one screen.

`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>
@github-actions

Copy link
Copy Markdown

🎉 Bazel & CI Test Results

Test Suite Result
valdi_web Integration Test ✅ success
Linux: C++ Tests ✅ success
Linux: Build & Export ✅ success
API Surface Check ✅ success
Snapshot Tests ✅ success
macOS: C++ & Platform Tests ✅ success
Linux: Build Compiler ✅ success
Valdi Smoke Tests ✅ success

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant