2012-02-16 87 views
0

我應該如何從我的應用程序打開主屏幕?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

回答

0
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); 
相關問題