现在的位置: 首页 > 综合 > 正文

Android判断apk是否存在

2017年11月14日 ⁄ 综合 ⁄ 共 412字 ⁄ 字号 评论关闭

Android判断某个apk是否存在:

public  boolean isPkgInstalled(Context context, String packageName) {

        if (packageName == null || "".equals(packageName))
            return false;
        android.content.pm.ApplicationInfo info = null;
        try {
            info = context.getPackageManager().getApplicationInfo(packageName, 0);
            return info != null;
        } catch (NameNotFoundException e) {
            return false;

        }

packageName:apk的 包名

抱歉!评论已关闭.