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.

bug: Hardware back button closes app on Android

See original GitHub issue

Bug Report

Ionic version:

[x] 5.x

Current behavior:

When pressing the hardware back button on an Ionic app before doing anything else, it will close the app. This does not happen if you interact with the app in any way first, like touching somewhere on the screen.

Expected behavior:

I would expect the app to not close?

Steps to reproduce:

  1. Create a new cordova project with ionic cli
  2. Run ionic cordova run android
  3. Press hardware back button
  4. App should now close

Related code:

Other information:

I do not know if this is an Ionic issue or if the problem lies somewhere else, but I thought I would give a heads up. Also this doesn’t seem to be listed in the hardware back button consolidated list of issues.

Ionic info:

Ionic:

   Ionic CLI                     : 6.13.1 (C:\Users\<user>\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 5.6.4
   @angular-devkit/build-angular : 0.1102.8
   @angular-devkit/schematics    : 11.2.8
   @angular/cli                  : 11.1.4
   @ionic/angular-toolkit        : 3.1.1

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : android 9.0.0
   Cordova Plugins   : not available

Utility:

   cordova-res : not installed
   native-run  : 1.3.0

System:

   Android SDK Tools : 26.1.1 (C:\AndroidSDK)
   NodeJS            : v15.11.0 (C:\Program Files\nodejs\node.exe)
   npm               : 7.6.0
   OS                : Windows 10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:24 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
liamdebeasicommented, Apr 19, 2021

I can reproduce this behavior, though only on newer versions of Android. In addition, I can reproduce this in a regular Angular app without Ionic Framework, so I need to do some more digging to see what could be causing this issue.

1reaction
liamdebeasicommented, May 17, 2021

No problem, glad the issue is resolved 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic Capacitor hardware back button is automatically closing ...
//back button handle //Registration of push in Android and Windows ... The Problem is, when I build a release app, it still closes...
Read more >
Android Back Button causes crashing/closing - sometimes
bug. Pressing the Back key will close/crash my app about 50% of the time. I am able to reproduce this issue using the...
Read more >
Back button issues - Samsung Members Community
Hi, I am having issues with my back button not working as it should. Sometimes when I press the back button it completely...
Read more >
App destroyed after back button pressed - Ionic Native
I Used IONIC 5 and ANgular 11 ,. When I click on the Bakc button the application close automatically. I see only this...
Read more >
Android back button should close the selected tab and return ...
In the Android native UI, when I select menu->More->Add-ons, about:addons opens in a new tab in my browser. I then click the back...
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