Android Package Manage isPackageInstalled(String packageName, PackageManager pm)

Here you can find the source of isPackageInstalled(String packageName, PackageManager pm)

Description

is Package Installed

Declaration

public static boolean isPackageInstalled(String packageName,
            PackageManager pm) 

Method Source Code

//package com.java2s;

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

import android.util.Log;

public class Main {
    private static final String TAG = Thread.currentThread()
            .getStackTrace()[1].getClassName();

    public static boolean isPackageInstalled(String packageName,
            PackageManager pm) {// w w w .  j a  va 2 s . co  m
        try {
            String mVersion = pm.getPackageInfo(packageName, 0).versionName;
            if (mVersion == null) {
                return false;
            }
        } catch (NameNotFoundException notFound) {
            Log.e(TAG, "Package could not be found!", notFound);
            return false;
        }
        return true;
    }
}

Related

  1. getApplicationIcon(String packageName)
  2. getUidForPackageName(PackageManager pm, String packageName)
  3. disableComponent(PackageManager pm, ComponentName component)
  4. enableComponent(PackageManager pm, ComponentName component)
  5. getApplicationMarketPage( @Nonnull String packageName)
  6. isPackageInstalled(final String packageName, final PackageManager pm)
  7. isSpeechRecognitionActivityPresented( Activity callerActivity)
  8. uninstall(Context context, String packageName)