How to exit from an app on back press of main activity? I am using this code, but its finish main activity and show other activities from back stack.
@Override
public void onBackPressed() {
finish();
}
I tried this and its work for me really well,as I am working on app, where once session get expired, user is able to see only few views and remain hidden.
@Override
public void onBackPressed() {
moveTaskToBack(true);
}