Android检查手机上是否安装了指定的软件(根据包名检测)

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