码迷,mamicode.com
首页 > 其他好文 > 详细

检查应用是否安装

时间:2015-01-15 12:56:59      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

private boolean isAvilible(Context context, String packageName) {
if (packageName == null || "".equals(packageName))
return false;
PackageManager pageManage = getPackageManager();
List<PackageInfo> packages = pageManage.getInstalledPackages(0);
for (int i = 0; i < packages.size(); i++) {
PackageInfo packageInfo = packages.get(i);
String appName = packageInfo.applicationInfo.loadLabel(
getPackageManager()).toString();
String pagName = packageInfo.packageName;
if (appName.contains(packageName)) {
return true;
}
}
return false;

}



/**
* 检测该包名所对应的应用是否存在

* @param packageName
* @return
*/
public boolean checkPackage(String packageName) {
if (packageName == null || "".equals(packageName))
return false;
try {
getPackageManager().getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}

检查应用是否安装

标签:

原文地址:http://blog.csdn.net/abc546201056/article/details/42739667

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!