/** * 打开一个app * * @param packageName * @param data * @return */ public static boolean lanuchApp(Context context,String packageName, Bundle data) { try { Intent resolveIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); if (resolveIntent == null) { PackageInfo p = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); if (p != null) { resolveIntent = new Intent(packageName); } } if (resolveIntent != null) { if (data == null){ data = new Bundle(); } data.putBoolean("a", true); resolveIntent.putExtras(data); resolveIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(resolveIntent); return true; } } catch (Exception e) { } return false; }
时间: 2024-12-12 16:14:08