Example : I have 3 Activities, A,B, and C. from Activity A I open Activity B then From B open Activity C. Then I exit application by code :
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
System.exit(0);
I use this code for exit app. But when restart app, back again to recent Activity. My question, How to finish all Activities when exit from app?
You must be back to your main activity first by this code:
And then you will exit your application from mainActivity like this:
Hope it helps.