Skip to content

bug: Hardware Back Button control on Android does not work well. However, if there is no screen transition. #21265

@acn-masatadakurihara

Description

@acn-masatadakurihara

Bug Report

Ionic version:

[x] 5.1

Current behavior:

On Android, pressing the back button on the first page of a project always causes the app to close.
This happens absolutely even if the control of the back button is overridden so as not to quit the application according to the following Hardware Back Button.
However, once you have moved to another screen, the app will not exit even if you go back to the first page and press the back button.
https://github.com/ionic-team/ionic-docs/blob/master/src/pages/developing/hardware-back-button.md

Expected behavior:

Even if the screen transition is not performed, the overwriting process of Hardware Back Button is executed and the application is not terminated.

Steps to reproduce:

Related code:

I've pushed a sample below.
https://github.com/masatada-kurihara/ionic-back-button-test

The overwriting process of the back button is described in the NgOninit of HomePage, but the moment I start the application, the process is not executed.
After the transition to FugaPage, the back button overwriting process is enabled.

Other information:

Probably not occurring in ionic4.8.1.

Ionic info:

Ionic:

   Ionic CLI                     : 6.8.0 (/Users/masatada.kurihara/.nvm/versions/node/v12.9.1/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.1.0
   @angular-devkit/build-angular : 0.803.26
   @angular-devkit/schematics    : 8.3.26
   @angular/cli                  : 8.3.26
   @ionic/angular-toolkit        : 2.2.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : not available
   Cordova Plugins   : not available

Utility:

   cordova-res                          : not installed
   native-run (update available: 1.0.0) : 0.2.8

System:

   Android SDK Tools : 26.1.1 (/Users/masatada.kurihara/Library/Android/sdk)
   ios-deploy        : 1.9.4
   NodeJS            : v12.9.1 (/Users/masatada.kurihara/.nvm/versions/node/v12.9.1/bin/node)
   npm               : 6.13.7
   OS                : macOS Catalina
   Xcode             : Xcode 11.4.1 Build version 11E503a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions