back-button-control

How to handle back button on Ionic 2

一笑奈何 提交于 2019-11-27 01:04:31
How can I handle the back button action on Ionic 2? I want to be able to know what to do depending on which page is being shown to the user. I didn't find a good answer to this question, but after a while I figured it out myself a way to do it. I'm gonna share with you all. Thanks Here's how I did it: In every Page component, I created a function called backButtonAction() , which will execute custom code for every page. Code: import { Component } from '@angular/core'; import { Platform, NavController, ModalController } from 'ionic-angular'; import { DetailsModal } from './details'; @Component(

How to handle back button on Ionic 2

二次信任 提交于 2019-11-26 17:28:04
问题 How can I handle the back button action on Ionic 2? I want to be able to know what to do depending on which page is being shown to the user. I didn't find a good answer to this question, but after a while I figured it out myself a way to do it. I'm gonna share with you all. Thanks 回答1: Here's how I did it: In every Page component, I created a function called backButtonAction() , which will execute custom code for every page. Code: import { Component } from '@angular/core'; import { Platform,

how to close android app completely

核能气质少年 提交于 2019-11-26 16:08:19
问题 I created an android application with a logout option in onCreateOptionsMenu . The Logout works perfectly but when I press the back button again it takes me to the previous activity, and when it gets a null value it redirects to login screen. Now my login screen appears again and again. I want to close the app completely when I press the back button but don't know how. Here is my code to handle the back button press in the login screen: @Override public void onBackPressed() { new AlertDialog