Android examples for App:Package
is Package Exists
//package com.java2s; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static boolean isPackageExists(Context context, String packageName) { if (null == packageName || "".equals(packageName)) { throw new IllegalArgumentException( "Package name cannot be null or empty !"); }/* www . ja v a2 s.co m*/ try { ApplicationInfo info = context.getPackageManager() .getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); return null != info; } catch (NameNotFoundException e) { return false; } } }