2012-09-20 72 views

回答

39

給定一個名爲ResolveInfolaunchable

ActivityInfo activity=launchable.activityInfo; 
ComponentName name=new ComponentName(activity.applicationInfo.packageName, 
            activity.name); 
Intent i=new Intent(Intent.ACTION_MAIN); 

i.addCategory(Intent.CATEGORY_LAUNCHER); 
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | 
      Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 
i.setComponent(name); 

startActivity(i); 

(從https://github.com/commonsguy/cw-omnibus/tree/master/Introspection/Launchalot

+0

工作完美,謝謝! –

+0

一切正常,但每個應用程序都有圖標的大小,這裏不管理 –

20

通過建立這樣一個新的意圖。

Intent intent = new Intent(); 
    intent.setClassName(resolveInfo.activityInfo.applicationInfo.packageName, 
      resolveInfo.activityInfo.name); 
    startActivity(intent); 
+1

哇簡單和短... –

+1

可能會縮短第二行嗎? intent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name); –