Here you can find the source of isPackageInstalled(String packageName, PackageManager pm)
public static boolean isPackageInstalled(String packageName, PackageManager pm)
//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; } }