I want to launch home screen of Android with my application. The main target is to show all of apps to user when he/she presses a specialized key. Actually, the way is not important. Any idea to do this?
9 Answers
Here is the code for starting HomeActivity
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);

- 1,315
- 1
- 12
- 18
-
1Thx but I want to open the screen that shows apps with their icons to users. I meant this while saying "home screen". – sjor Jan 21 '11 at 08:58
-
Yes, that is what he's talking about – grepsedawk Apr 23 '12 at 00:10
-
This code is no longer working in Redmi Note 5 Pro MIUI Global 11.0.3 version. Does anyone know any wayout? – Sudipto Mukherjee Jul 08 '20 at 12:27
-
Hi @SudiptoMukherjee have you found anything on this? I am facing same issue on Samsung S20+ android 11. – amit semwal Apr 19 '21 at 11:01
The comments you made on some of the answers suggest you actually want to launch the Launcher (you may want to update the title if this is the case). To do this, use the same approach Anand proposed for launching the home activity.
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_LAUNCHER);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);

- 4,224
- 5
- 37
- 74
-
1
-
3This will just open up an app (or show a list of apps) that have the "launcher" category, which is most of them. It explains the behavior reported by rekire. – pents90 May 29 '14 at 21:36
There is no "screen that shows apps with their icons to users" in Android.
What you are thinking of is a feature of some home screens. There is no standardized Intent
to trigger this to appear, and there is no requirement for home screens to have such a feature.
You are welcome to write your own. Here is a sample project that displays launchable activities in a ListView
.

- 986,068
- 189
- 2,389
- 2,491
-
Hi Sir, i need you help, i tried to create a sample screen locker it works fine, my problem is after the screen lock, the it navigates to device default home, when i click in home button it will launched my launcher but in need to show the default home after the unlock, how can i do it. – Aerrow Dec 17 '13 at 07:55
try something like this to click back button any you will goto home screen/...
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
// Display confirmation here, finish() activity.
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
return true;
}
return super.onKeyDown(keyCode, event);
}

- 1,357
- 1
- 15
- 29
None of the solutions here is working for me..
I got it working by using the below code
PackageManager pm = getPackageManager();
Intent i = new Intent("android.intent.action.MAIN");
i.addCategory("android.intent.category.HOME");
List<ResolveInfo> lst = pm.queryIntentActivities(i, 0);
if (lst != null) {
for (ResolveInfo resolveInfo : lst) {
try {
Intent home = new Intent("android.intent.action.MAIN");
home.addCategory("android.intent.category.HOME");
home.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
startActivity(home);
break;
} catch (Throwable t) {
t.printStackTrace();
}
}
}
Got it from: https://stackoverflow.com/a/16483596/1241783
Hope this helps someone
I think I am very late to the party, but I had a similar concern. The answers given here launch a selection menu which allows you to choose the Launcher. If you have more than one launcher in your code, the answer here: https://stackoverflow.com/a/8666155 might be of help. This directly launches the default home screen of Android.

- 1
- 1

- 11
- 3
I have attain it using one line
moveTaskToBack(true); //activity.moveTaskToBack(true);
It behave like Home Button

- 33,936
- 20
- 234
- 300
I am not sure if I completely understand what you are trying to do! But if you mean that you want the user to be able to another application by clicking inside your application, then you should check out "intent". Run the API DEMO sample code in eclipse, and run App -> Intents

- 5,577
- 11
- 68
- 110
This is working good for me!
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startActivity(startMain);
can somebody explain why we need this ?
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
btw, this is what I was looking for
moveTaskToBack(true);

- 863
- 9
- 20