You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
backbutton fires twice for one Back key press on Android 16 #2028
One press of the Back key fires one backbutton event.
What does actually happen?
One press of the Back key fires backbutton twice, about 0.4 ms apart.
A back gesture (edge swipe) fires it once.
Apps that navigate back on backbutton go back two screens for one press.
Information
The same key press reaches CordovaWebViewImpl.onDispatchKeyEvent by two paths (logcat stacks are in the repro repo):
ViewRootImpl$NativePreImeInputStage.doOnBackKeyEvent -> OnBackPressedDispatcher -> the callback from CoreAndroid.overrideBackbutton -> dispatchBackKeyEvent() -> synthetic key -> backbutton.
The real key event continues to ViewRootImpl$ViewPostImeInputStage -> DecorView -> SystemWebView.dispatchKeyEvent -> backbutton.
The synthetic path comes from #1903 and #1910. The code is the same on master.
You can test it in a fresh Cordova test project by adding the Android platform from the PR branch:
cordova platform add android@https://github.com/GitToTheHub/cordova-android.git#fix/android-backbutton-once-2028
cordova run android
Keep your backbutton counter in the test app and try both a Back key press (adb shell input keyevent KEYCODE_BACK or three-button navigation) and an edge-swipe gesture. Each input should fire exactly one event.
I verified this on Android 15 and 16 emulators, including rapid consecutive presses. Please let me know whether it also resolves the duplication in your reproduction app.
Activity
GitToTheHub commentedon Oct 12, 2026
I created a fix in PR #2029.
You can test it in a fresh Cordova test project by adding the Android platform from the PR branch:
Keep your
backbuttoncounter in the test app and try both a Back key press (adb shell input keyevent KEYCODE_BACKor three-button navigation) and an edge-swipe gesture. Each input should fire exactly one event.I verified this on Android 15 and 16 emulators, including rapid consecutive presses. Please let me know whether it also resolves the duplication in your reproduction app.
fix(android): handle each back action once (apache#2029)