安卓判断APP是否安装并且未禁用

/**
 * check the app is installed
 */
public static boolean isAppInstalled(String packageName) {
    PackageInfo packageInfo;
    ApplicationInfo applicationInfo = null;
    try {
        packageInfo = CCApplication.getInstance().getPackageManager().getPackageInfo(packageName, 0);
        applicationInfo = AppContext.getContext().getPackageManager().getApplicationInfo(packageName, 0);
    } catch (PackageManager.NameNotFoundException e) {
        packageInfo = null;
        e.printStackTrace();
    }
    if (packageInfo != null && applicationInfo != null && applicationInfo.enabled) {
        return true;
    } else {
        return false;
    }
}

你可能感兴趣的:(安卓判断APP是否安装并且未禁用)