Route back through the AndroidX dispatcher (predictive back silently kills both overrides at 36)#12
Open
xroche wants to merge 1 commit into
Open
Route back through the AndroidX dispatcher (predictive back silently kills both overrides at 36)#12xroche wants to merge 1 commit into
xroche wants to merge 1 commit into
Conversation
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>
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.
At targetSdk 36
enableOnBackInvokedCallbackdefaults to true and the system stops callingonBackPressed(), 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.OptionsActivityloses the most. Its override callssave(), and itselsebranch 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 frameworkActivity, which has noOnBackPressedDispatcherat all, so it moves toFragmentActivity; it uses no fragments, and nothing else about it changes. The branch that calledsuper.onBackPressed()and thenfinish()now simply finishes, which is what that pair amounted to, andfinish()is overridden there to carry the settings back.HTTrackActivityis aFragmentActivityalready, 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 oldifwas really expressing.The result is one path for both eras: with no override left,
ComponentActivityroutes today's back through the same dispatcher thatOnBackInvokedCallbackreaches at 36.Verified: no
onBackPressedoverride remains, and lint is unchanged against master (2 errors, 10 fatalInstantiatable, all pre-existing). Behaviour needs a device, which is not available yet.