views:

142

answers:

3

I have an application wherein on homepage i have buttons for navigation through the application.

In that I have a button "EXIT" which when clicked should take user to home screen on the phone where the application icon is.

How can I do that?

+4  A: 

It is not recommended to exit your Android Application. See this question for more details.

The user can always quit your app through the home button or in the first activity through the back button.

Janusz
i got concept after reading that page. thanks
poojan9118
+2  A: 

Hi,

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

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
ognian
+3  A: 

Is you simply want to end an activity you can call finish(). It however bad practice to have an exit button on the screen.

Christian