Check For Installed App : System « Development « Android






Check For Installed App

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

class Main {
  public static boolean checkForInstalledApp(Context ctx, String pkgName) {
    try {
      PackageManager pm = ctx.getPackageManager();
      pm.getPackageInfo(pkgName, 0);
      // Log.d(TAG, pkgString + " is installed");
      return true;
    } catch (NameNotFoundException e) {
      // Log.d(TAG, pkgString + " is not installed");
    }
    return false;
  }

}

   
    
    
    
  








Related examples in the same category

1.Run System Command
2.Get Process ID with shell command and read by Java code
3.Get App Name
4.Get Api Level
5.Exec And Wait