如何在自己的app中通过包名启动其他的app
public Intent panduan_apps_to_list_all(String baoName) { int saomiao = 0; PackageManager pm = this.getPackageManager(); // 获得PackageManager对象 Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); // 通过查询,获得所有ResolveInfo对象. // wjz GET_UNINSTALLED_PACKAGES:所有的程序吧,包括SD卡 // MATCH_DEFAULT_ONLY:只是系统程序 List<ResolveInfo> resolveInfos = pm.queryIntentActivities(mainIntent, PackageManager.GET_UNINSTALLED_PACKAGES); // 调用系统排序 , 根据name排序 // 该排序很重要,否则只能显示系统应用,而不能列出第三方应用程序 Collections.sort(resolveInfos, new ResolveInfo.DisplayNameComparator(pm)); int len = resolveInfos.size(); for (ResolveInfo reInfo : resolveInfos) { saomiao++; String activityName = reInfo.activityInfo.name; // 获得该应用程序的启动Activity的name String pkgName = reInfo.activityInfo.packageName; // 获得应用程序的包名 String appLabel = (String) reInfo.loadLabel(pm); // 获得应用程序的Label // Drawable icon = reInfo.loadIcon(pm); // 获得应用程序图标 if (pkgName.equals(baoName)) { // 为应用程序的启动Activity 准备Intent Intent launchIntent = new Intent(); launchIntent.setComponent(new ComponentName(pkgName, activityName)); return launchIntent; } } return null; }