If you use the
This.app.getRootNav (). push () and This.navCtrl.push (); when registering the Android return key registerbackbuttonaction () { if (!this.nativeservice.isandroid ()) { return; } this.platform.registerbackbuttonaction (() = { if (This.keyboard.isOpen ()) {//Hide keyboard If keyboard is turned on this.keyboard.close (); return; } // Click the Back button to hide the toast or loading or overlay this.ionicapp._ Toastportal.getactive () | | This.ionicapp._loadingportal.getactive () | | This.ionicapp._overlayportal.getactive (); //Hide modal let Activeportal = this.ionicapp._ Modalportal.getactive (); if (activeportal) { activeportal.dismiss (); return; } //Page return if ( This.app.getRootNav (). CanGoBack ()) { // This.showexit () this.nativeService.minimize () return this.app.goBack () }else{ return This.showexit (); } }, }//double-exit the prompt box showexit () { if (this.backButtonPressed) {// When the trigger flag is true, double-click the return button within 2 seconds to exit app THIS.PLATFORM.EXITAPP (); } else { this.nativeservice.showtoast (' Press again to exit the app '); this.backbuttonpressed = true; settimeout (() = {///2 seconds without clicking back again marks the trigger flag as false this.backbuttonpressed = false; }, } ) }
IONIC2/3 register for Android back