4

There is this code (taken from https://stackoverflow.com/a/5016624/1369016):

private boolean isAppInstalled(String packageName) {
   PackageManager pm = getPackageManager();
   boolean installed = false;
   try {
      pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
      installed = true;

   } catch (PackageManager.NameNotFoundException e) {
      installed = false;
   }
   return installed;
}

But I don't know what to put in the packageName. I tried com.google.android.gms.wallet (which is the package of some Wallet fragments used by Android Pay) but the above method returns false.

Community
  • 1
  • 1

2 Answers2

6

It turns out the package name required is "com.google.android.apps.walletnfcrel". With that you can call the method in the question to detect if Android Pay is installed.

-1

on Kotlin:

private fun isAppInstalled(packageName: String): Boolean {
    return try {
        activity?.packageManager?.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES)
        true
    } catch (e: PackageManager.NameNotFoundException) {
        false
    }
}
vlasentiy
  • 342
  • 1
  • 6
  • 12