WEB开发网
开发学院手机开发Android 开发 在android里启动一个新的程序 阅读

在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 appList = pm.queryIntentActivities

(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);

Tags:android 启动 一个

编辑录入:coldstar [复制链接] [打 印]
赞助商链接