android 判断应用是否安装
1个回答
展开全部
public static boolean checkApkExist(Context context, String packageName) {
if (TextUtils.isEmpty(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager()
.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
if (info == null) {
return false;
} else {
return true;
}
} catch (NameNotFoundException e) {
return false;
}
}
if (TextUtils.isEmpty(packageName))
return false;
try {
ApplicationInfo info = context.getPackageManager()
.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
if (info == null) {
return false;
} else {
return true;
}
} catch (NameNotFoundException e) {
return false;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询