I have an application where on the home page I have buttons for navigation through the application.
On that page I have a button \"EXIT\" which when clicked should t
if you want to exit application put this code under your function
public void yourFunction()
{
finishAffinity();
moveTaskToBack(true);
}
//For an instance, if you want to exit an application on double click of a
//button,then the following code can be used.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 2) {
// do something on back.
From Android 16+ you can use the following:
finishAffinity();
moveTaskToBack(true);
}
return super.onKeyDown(keyCode, event);
}