Implementing device back button android

Hey all,

I want to implement the device back button on the Android device. But when open the modal and press the back button it exits the app. Same for other pages. I want to exit the app when the tabToot page is set to one. Can anyone tell me what are the best practices for implementing this?

Try this code.

import { NavController, NavParams, Platform } from 'ionic-angular';

export class HomePage{
        constructor(public platform:Platform){
               alert("pressed back button");

Thanks ravi_sojitra!

But I have tried already. But no luck. I want to pop the pages end of the stack and then exit the app.