Android:我应该如何从我的应用程序打开主屏幕?

问题描述:

我应该如何从我的应用程序打开主屏幕?Android:我应该如何从我的应用程序打开主屏幕?

Intent i = new Intent(Intent.ACTION_MAIN); 
PackageManager manager = getPackageManager(); 
i = manager.getLaunchIntentForPackage("com.android.launcher"); 
startActivity(i); 

此代码的工作,当我打开

com.android.browser 

但是,这不是工作

com.android.launcher 

可能是什么问题?包名或其他?

任何帮助将不胜感激。

+0

可能重复[以编程方式进入主屏幕](http://stackoverflow.com/questions/3724509/going-to-home-screen-programmatically) – 2012-02-16 14:19:34

ask the user to open any app 

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