Skip to content

[Android] mBackPressedCallback not re-enabled after hardware back handler is called #227

Closed

Description

@lujjjh

When React Native does not handle a back press (for example, when the navigation stack is already empty), setHardwareBackHandler disables mBackPressedCallback and manually dispatches the back event to the host Activity:

// invoked on the last RN screen exit
resolvedDelegate.setHardwareBackHandler {
mBackPressedCallback.isEnabled = false
activity?.onBackPressedDispatcher?.onBackPressed()
}

I’m not fully sure whether this behavior is intentional, but the issue I’m encountering is that once React Native declines to handle a back press, subsequent back presses are never delivered to React Native again.

Expected behavior

If React Native does not handle a back press, the event should be forwarded to the Activity, but React Native should still be able to receive future back press events.

Proposed fix

I applied the patch, and everything seems to be working as expected.

diff --git a/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt b/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt
index 7224c488ae1222bd0b56a93b3388b4eb953f6824..5342782367704d0a34ff47bccac529630b064dc9 100644
--- a/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt
+++ b/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt
@@ -134,6 +134,7 @@ class ReactNativeBrownfield private constructor(val reactHost: ReactHost) {
         resolvedDelegate.setHardwareBackHandler {
             mBackPressedCallback.isEnabled = false
             activity?.onBackPressedDispatcher?.onBackPressed()
+            mBackPressedCallback.isEnabled = true
         }

         /**

If this fix makes sense, I’m happy to open a PR.

Activity

  1. hurali97 commented on Feb 17, 2026

    @hurali97
    Member

    Hi @lujjjh - Is it possible for you to share a reproducer? We can then quickly verify the behavior and if it is legit, then we would love a PR 👍

  2. marcinszalski-callstack commented on Apr 3, 2026

    @marcinszalski-callstack
    Contributor

    issue reproduced with the repo's sample app, dummy toast added in the native Activity to show when the native layer got a chance to respond to the close-app intent from user.
    PR - #288

  3. hurali97 commented on Apr 9, 2026

    @hurali97
    Member

    CLosing as #288 is merged and released v3.5.1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions