Skip to content

Route back through the AndroidX dispatcher (predictive back silently kills both overrides at 36)#12

Open
xroche wants to merge 1 commit into
masterfrom
predictive-back
Open

Route back through the AndroidX dispatcher (predictive back silently kills both overrides at 36)#12
xroche wants to merge 1 commit into
masterfrom
predictive-back

Conversation

@xroche

@xroche xroche commented Jul 17, 2026

Copy link
Copy Markdown
Owner

At targetSdk 36 enableOnBackInvokedCallback defaults to true and the system stops calling onBackPressed(), so both of the app's overrides quietly stop running. No crash, no log, nothing a build or lint check can see. Landing it now, while the target is still 25 and the AndroidX dispatcher is already the path back takes, keeps the eventual bump a one-variable change.

OptionsActivity loses the most. Its override calls save(), and its else branch is the entire "leave a sub-tab" navigation, so bypassed it would both drop the settings and walk out of the options screen instead of returning to the menu. It extended the framework Activity, which has no OnBackPressedDispatcher at all, so it moves to FragmentActivity; it uses no fragments, and nothing else about it changes. The branch that called super.onBackPressed() and then finish() now simply finishes, which is what that pair amounted to, and finish() is overridden there to carry the settings back.

HTTrackActivity is a FragmentActivity already, but that does not save it: the dispatcher does not re-enter a subclass override either, so its guard against finishing mid-crawl (the retained fragment holds the runner) was equally dead. Rather than intercept every back and re-dispatch the ones it does not want, its callback is enabled only on the progress pane, which is the condition the old if was really expressing.

The result is one path for both eras: with no override left, ComponentActivity routes today's back through the same dispatcher that OnBackInvokedCallback reaches at 36.

Verified: no onBackPressed override remains, and lint is unchanged against master (2 errors, 10 fatal Instantiatable, all pre-existing). Behaviour needs a device, which is not available yet.

At targetSdk 36 enableOnBackInvokedCallback defaults to true and the system
stops calling onBackPressed(), so both overrides would quietly stop running.
Neither failure announces itself.

OptionsActivity loses the most: its override calls save(), and its else
branch is the whole "leave a sub-tab" navigation. Bypassed, back would drop
the settings and walk out of the options screen instead of returning to the
menu. It extended the framework Activity, which has no dispatcher at all,
hence FragmentActivity; it uses no fragments, so nothing else moves. The
branch that called super.onBackPressed() then finish() now just finishes,
which is what that pair amounted to, and finish() is overridden here to
carry the settings back.

HTTrackActivity is a FragmentActivity already, but the dispatcher does not
re-enter a subclass override either, so its guard against finishing mid-crawl
was equally dead. Rather than intercept every back and re-dispatch the ones
it does not want, the callback is enabled only on the progress pane, which is
the condition it was really expressing.

One path now serves both: with no override left, ComponentActivity routes
today's back through the same dispatcher that OnBackInvokedCallback will
reach at 36.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
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