Android判断是否安装某个应用程序
RT,贴代码:
1 public boolean isPackageExist(pkgName){ 2 boolean isExist = false; 3 final PackageManager packageManager = this.getPackageManager(); 4 List<PackageInfo> pinfo = packageManager.getInstalledPackages(0); 5 List<String> pName = new ArrayList<String>(); 6 if (pinfo != null) { 7 for (int i = 0; i < pinfo.size(); i++) { 8 String pn = pinfo.get(i).packageName; 9 pName.add(pn); 10 } 11 } 12 if (pName.contains(pkgName)) { 13 isExist = true; 14 } else { 15 isExist = false; 16 } 17 return isExist; 18 }