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.

v4: Android hardware back button doesn't work

See original GitHub issue

Bug Report

Ionic Info Run ionic info from a terminal/cmd prompt and paste the output below.

Ionic:

   ionic (Ionic CLI)          : 4.0.0-rc.9 (C:\Users\ape\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework            : @ionic/angular 4.0.0-alpha.7
   @angular-devkit/core       : 0.6.8
   @angular-devkit/schematics : 0.6.8
   @angular/cli               : 6.0.8
   @ionic/ng-toolkit          : not installed
   @ionic/schematics-angular  : 1.0.0-rc.9

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 6.3.0 ios 4.5.4

System:

   Android SDK Tools : 25.2.5
   NodeJS            : v10.5.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.1.0
   OS                : Windows 10

Describe the Bug Android hardware button doesn’t work as intended. It seems to be because of back button behavior overriding in generated cordova.js:

var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
        backButtonChannel.onHasSubscribersChange = function() {
            // If we just attached the first handler or detached the last handler,
            // let native know we need to override the back button.
            exec(null, null, APP_PLUGIN_NAME, "overrideBackbutton", [this.numHandlers == 1]);
        };

which is caused by:

https://github.com/ionic-team/ionic/blob/181cd559cc68542d48a33e6ff58408e2ffc2077c/angular/src/providers/platform.ts#L42

Steps to Reproduce Steps to reproduce the behavior:

  1. Clone repo https://github.com/ionictheme/ionic4-start-theme
  2. Install deps and run on device
  3. Click on android hardware back button
  4. Nothing happens

Expected Behavior Android hardware back button should return the previous page or exit app.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Riyaz0001commented, Sep 15, 2018

this.platform.exitApp(); doesn’t work for ionic v4.1.2

1reaction
ptitjescommented, Sep 21, 2018

@manucorporat PR https://github.com/ionic-team/ionic/pull/15615 fixes the remaining problem with the handler registered by overlays.tsx.

Read more comments on GitHub >

github_iconTop Results From Across the Web

v4: Android hardware back button doesn't work · Issue #14803
I have to tap it twice in order for doit() to be called. It does not happen, when I got back with the...
Read more >
Hardware back button doesn't the app on Android with Ionic 4
I am facing problem with the hardware back button on android. I am working with Ionic CLI 4.12.0 I want to exit the...
Read more >
On screen back button not working - XDA Forums
Go to google settings and reset ! The BACK button will work again!
Read more >
Android Home Back Button keys Not Working Damaged
This video will help onhow to solve android Back key Home key, Menu key, recent button not working problemHow to enable soft-keys navigation ......
Read more >
How To Bring Back The Android Back Button [Back ... - YouTube
There is no Back Button, Home Button, and Switch Apps Button on your Android Phone Screen, and you want to bring them 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