梳理下流程:
枚举对应浏览器包名到数组中
数组循环根据包名找到对应的LaunchIntent
通过LaunchIntent找到对应的LaunchActivity的包名
Intent通过设置activity的包名+类名
/**
* 工具类
*/
public class CheckApkExist {
private static String ucPkgName = "com.uc.browser";
public static boolean checkApkExist(Context context, String packageName){
if (TextUtils.isEmpty(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager()
.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
/** 示例:uc 浏览器检测*/
public static boolean checkUCBrowserExist(Context context){
return checkApkExist(context, ucPkgName);
}
梳理下流程:
枚举对应浏览器包名到数组中
数组循环根据包名找到对应的LaunchIntent
通过LaunchIntent找到对应的LaunchActivity的包名
Intent通过设置activity的包名+类名
/**
* 工具类
*/
public class CheckApkExist {
private static String ucPkgName = "com.uc.browser";
public static boolean checkApkExist(Context context, String packageName){
if (TextUtils.isEmpty(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager()
.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
/** 示例:uc 浏览器检测*/
public static boolean checkUCBrowserExist(Context context){
return checkApkExist(context, ucPkgName);
}