Android 检查手机上是否安装了指定的软件(根据包名检测)
Android检查手机上是否安装了指定的软件(根据包名检测)
/** * 检查手机上是否安装了指定的软件 * @param context * @param packageName * @return */ public static boolean isAvilible(Context context, String packageName) { final PackageManager packageManager = context.getPackageManager(); List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0); List<String> packageNames = new ArrayList<String>(); if (packageInfos != null) { for (int i = 0; i < packageInfos.size(); i++) { String packName = packageInfos.get(i).packageName; packageNames.add(packName); } } // 判断packageNames中是否有目标程序的包名,有TRUE,没有FALSE return packageNames.contains(packageName); }