我们在开发中经常遇到 要开发的app打开第3方应用,并且第3方应用还没有图标,怎么实现呢?如下
要想打开没有 LAUNCHER 的第3方应用,第3方应用 在AndroidManifast.xml中必须加上android.intent.category.DEFAULT。
public static void openNoLauncherApk(String packageName,Context context) {
PackageManager packageManager = context.getPackageManager();
try {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.addCategory(packageName);
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent,
PackageManager.MATCH_ALL);
for (ResolveInfo resolveInfo : resolveInfos){
YdswLog.e(resolveInfo.activityInfo.packageName);
if (resolveInfo.activityInfo.packageName.equals(packageName)){
In