Android APK Installation Check isApkInstalled(Context context, String packageName)

Here you can find the source of isApkInstalled(Context context, String packageName)

Description

is Apk Installed

Declaration

public static boolean isApkInstalled(Context context, String packageName) 

Method Source Code

//package com.java2s;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

import android.util.Log;

public class Main {
    final public static String TAG = "AK_KaedeUtil";

    public static boolean isApkInstalled(Context context, String packageName) {
        PackageInfo packageInfo = null;/*from ww  w  .  j  av a  2 s  . c  o m*/

        try {
            packageInfo = context.getPackageManager().getPackageInfo(
                    packageName, PackageManager.GET_ACTIVITIES);
        } catch (NameNotFoundException e) {
            packageInfo = null;
            e.printStackTrace();
        }
        if (packageInfo == null) {
            return false;
        } else {
            Log.e(TAG, packageInfo.toString());
            return true;
        }
    }
}

Related

  1. isAppInstalled(Context ctx, String uri)
  2. installApk(Context context, File file)
  3. installApk(Context context, File file)
  4. uninstallApk(Context context, String packageName)
  5. verifySampleSetup(Activity activity, int... resIds)