首页 > 代码库 > 检查应用是否安装
检查应用是否安装
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;
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;
}
}
检查应用是否安装
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。