has Installed Apk - Android android.content.pm

Android examples for android.content.pm:Apk Install

Description

has Installed Apk

Demo Code

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.res.Resources;

public class Main{

    public static boolean hasInstallApk(Context context, String PackageName)
            throws NotFoundException {
        boolean flag = true;
        PackageManager mPm = context.getPackageManager();
        PackageInfo pkgInfo = null;//from   www.  ja va  2 s. c  o  m
        try {
            pkgInfo = mPm.getPackageInfo(PackageName,
                    PackageManager.GET_UNINSTALLED_PACKAGES);
        } catch (NameNotFoundException e) {
            flag = false;
        } catch (Exception ex) {
            flag = false;
            if (pkgInfo == null) {
                throw new NotFoundException();
            }
        }
        return flag;
    }

}

Related Tutorials