Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - What Intent does home button issue?

Tags:

android

I would like to know exactly what operation a devices home button performs? ie what intent, intent category and action is issued when you click on home button? that takes on back to the blank home screen. I would like to know what is involved in implementing this operation to occur when clicking on my own custom button. Thanks (PS I know it is not standard, but neither is my device).

like image 809
Androider Avatar asked Apr 02 '11 01:04

Androider


People also ask

What happens when home button is pressed Android?

Pressing the Home switches you from the app to the home screen, whilst leaving your app running in the background.

What is intent flag_ activity_ new_ task?

The flags you can use to modify the default behavior are: FLAG_ACTIVITY_NEW_TASK. Start the activity in a new task. If a task is already running for the activity you are now starting, that task is brought to the foreground with its last state restored and the activity receives the new intent in onNewIntent() .

How can I tell if my home button is pressed Android?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken a text view.

What is affinity in Android?

Task affinity lets you define which task an activity belongs to. By default, an activity has the same task affinity as its root activity. With task affinity, we can now separate activities into different tasks. <activity android:name=".Activity_A"


1 Answers

If you want to show the home screen, you can do it by:

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

Update: check this sample app: http://developer.android.com/resources/samples/Home/index.html

like image 138
Aleadam Avatar answered Oct 13 '22 22:10

Aleadam