How to exit from the application and show the home screen?

android, back-button, exit

Solution

Android's design does not favor exiting an application by choice, but rather manages it by the OS. You can bring up the Home application by its corresponding Intent:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Problem

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 take the user to the home screen on the phone where the application icon is. How can I do that?

Original source

Related problems