在android里启动一个新的程序
2010-05-26 06:05:00 来源:WEB开发网核心提示:首先感谢万能的google!PackageManager pm = this.getPackageManager();Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);mainIntent.addCategory(Intent.CATEGORY_LAUNC
首先感谢万能的google!
PackageManager pm = this.getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List
(mainIntent, 0);
Collections.sort(appList, new ResolveInfo.DisplayNameComparator
(pm));
for(int i=0; i<>
mainText.setText(mainText.getText() + " " +
"number: " + i + " " +
"Name: " + appList.get(i).loadLabel(pm) + " "
);
}
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(new ComponentName(appList.get
(4).activityInfo.applicationInfo.packageName, appList.get
(4).activityInfo.name));
startActivity(i);
[]
更多精彩
赞助商链接