check whether app installed - Android android.content.pm

Android examples for android.content.pm:App

Description

check whether app installed

Demo Code

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

public class Main {

  /**/*  ww  w.  j a  va 2 s.  c om*/
   * check whether app installed
   *
   * @param context
   * @param packageName
   * @return
   */
  public static boolean checkAppInstalled(Context context, String packageName) {

    try {
      context.getPackageManager().getApplicationInfo(packageName,
          PackageManager.GET_INSTRUMENTATION);
      return true;
    } catch (NameNotFoundException e) {
      return false;
    }
  }

}

Related Tutorials