question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consolidated list of Android hardware back button issues

See original GitHub issue

Describe the Bug This is a list of functionality that must work with the Android hardware back button. I want to try and keep a list of them in one place so we can finally verify the hardware back button works correctly as this has been problematic since v2.

The back button here refers to the hardware back button.

Web Browser

  • Back button to navigate back to previous view.
  • (https://github.com/ionic-team/ionic/issues/15422) If a modal is open, back button to close/dismiss the modal.
  • If more than one modal is open at a time, back button should dismiss modals in the order they were opened (stack).
  • If a popup is open, the back button should dismiss any popup.
  • If a popup is open on top of a modal, the popup should be dismissed first on back button press.
  • Pressing back in a tabbed application should navigate the user backward across tabs. (for example: Tab 1 -> Page 1 -> Page 2 -> Tab 2 -> Page 3 -> back -> Page 2 -> back -> Page 1) (similar issue: https://github.com/ionic-team/ionic/issues/18721)
  • When side menu is open, back button should close the side menu before navigating.

Cordova/Capacitor

  • (similar: #17689 #17984 #20713) When on the root page, pressing the back button should close the app (standard Android behaviour)

This will be possible in Ionic Framework v5.1. There will also be docs added that will show how to do this.

  • (#19844) There should be an event that fires should the user want to show a confirmation popup before the back button closes the app.

This will be possible in Ionic Framework v5.1. There will also be docs added that will show how to do this.

Back button behaviour should be consistent between web and app (as per web list above)

Running in a Cordova/Capacitor app provides developers with additional tools to control the hardware back button functionality that does not exist in a web browser. For example, the ionBackButton event is only emitted in a Cordova/Capacitor app and is not emitted in a browser. As a result, hardware back button behavior when running in Cordova/Capacitor is currently not able to be perfectly aligned with the behavior when running that same app in a web browser; however, we will make the behavior as consistent as possible where appropriate.

#17589 back button not working with ion-button and href to page

This is the expected behavior. The hardware back button works within the context of your application’s navigation stack. Using href is going to cause a full page reload, thus emptying the stack. Similarly, if you did navController.navigateRoot, you probably would not then want the app to navigate to the previous page when tapping the hardware back button. Developers should try and stay within the scope of their framework’s routing solutions (I.e. using routerLink and related methods for Angular routing).

  • #17824 subscribeWithPriority not working properly w/ popups & higher priority levels

Fixed in Ionic Framework v5.1

Expected Behavior Ultimately the user should not need to have to intervene with events, subscriptions or HostListener to handle back button navigation.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:87
  • Comments:33 (4 by maintainers)

github_iconTop GitHub Comments

14reactions
liamdebeasicommented, Apr 4, 2019

Hi everyone,

We are aware of these issues and are going to be looking into them now. We are currently prioritizing these issues and hope to have more updates to share soon.

We appreciate your patience as we work through these issues. Thanks!

7reactions
moritzgloecklcommented, Mar 13, 2019

We’ve also noticed that the hardware back button on Android behaves differently than the browser back button, especially when using replaceUrl: true and skipLocationChange: true in Angular routing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hardware Back Button for Capacitor & Cordova on Android ...
The hardware back button is found on most Android devices. Read to learn more about hardware back button use in Capacitor and Cordova...
Read more >
Android Device Hardware Back Button is not working in ...
I am new to ionic framework. I have developed a simple app using ionic 4. It is working fine but Android Hardware back...
Read more >
A Comprehensive List of Issues Introduced in 12 and How ...
This will be an ongoing/regularly updated post of how to fix the issues introduced in OOS12 for people who don't want to have...
Read more >
How To Fix Back Button Not Working on iPhone and Android
Restart the Device · Check for a System Update · Wiping the System Cache Partition · Use a Third-party Back Button App ·...
Read more >
Android 12 features and changes list
The system Back button now moves an activity to the background instead of ... Android 12 introduces new APIs to verify device support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found