tags:

views:

90

answers:

2

I want to go to the home screen programmatically in android when the user clicks on button. How can this be done?

A: 

From Android developer site

Here are some examples of other operations you can specify as intents using these additional parameters:

* ACTION_MAIN with category CATEGORY_HOME -- Launch the home screen.
st0le
stOle there is nothing wrong with asking questions that can be answered with a quick google query and a look into the documentation. If the question contains the correct keywords it will show up on the first google page very quickly and makes finding the correct information and sample code much much faster then to look into the documentation. I'm a somehow trained android programmer but I would have to google and to skip over one or two pages to answer this question. It would be great if the answer to this question is here where it can be edited, improved, updated and rated.
Janusz
@Janusz, I didn't mean to sound harsh...
st0le
no problem. Even if Sridhar is not yet a good member of stackoverflow (0% accept rate) we don't need to push people away because they are not yet familiar with the system
Janusz
+1  A: 

You can do this through an Intent.

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

This Intent will start the launcher application that the user has defined. Be careful with this because this will look like your application crashed if the user does not expect this.

If you want this to build an exit button from your app please read this article on exit Buttons in Android

Janusz