Skip to content

Migrate remaining onBackPressed() overrides to OnBackPressedCallback #1566

@aaronbrethorst

Description

@aaronbrethorst

Background

PR #1563 fixed an issue where HomeActivity.onBackPressed() was silently bypassed on Android 13+ (API 33+) because modern Android routes back presses through WindowOnBackInvokedDispatcher → AndroidX OnBackPressedDispatcher, whose fallback calls ComponentActivity.super.onBackPressed() directly — skipping subclass overrides.

The same bug is likely present in other activities still using the deprecated onBackPressed() override pattern.

Affected files

  • onebusaway-android/src/main/java/org/onebusaway/android/ui/TripPlanActivity.java:261-267 — Has panel-collapse logic identical in shape to the HomeActivity bug; this is almost certainly broken on Android 13+.
  • onebusaway-android/src/main/java/org/onebusaway/android/report/ui/InfrastructureIssueActivity.java:722-726 — Resets mServicesSpinner after back; this side-effect is being skipped on Android 13+.

(SurveyViewUtils.java:148 uses onBackPressed() on a BottomSheetDialog, which is a separate dispatcher path — out of scope for this issue.)

Fix

Migrate each onBackPressed() override to register an OnBackPressedCallback with getOnBackPressedDispatcher() in onCreate(), mirroring the pattern from #1563.

Reference: https://developer.android.com/guide/navigation/custom-back

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions