Check that the Google Play Store exists on device

Fixes #3
This commit is contained in:
Björn Ritzl
2020-03-09 11:22:41 +01:00
parent 1c017cf4ed
commit 2843080690
3 changed files with 16 additions and 1 deletions

View File

@@ -155,10 +155,24 @@ public class IapGooglePlay implements Handler.Callback {
this.autoFinishTransactions = autoFinishTransactions;
}
private static boolean isPlayStoreInstalled(Context context){
try {
context.getPackageManager().getPackageInfo("com.android.vending", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
private void init() {
// NOTE: We must create Handler lazily as construction of
// handlers must be in the context of a "looper" on Android
if (!isPlayStoreInstalled(activity)) {
Log.e(TAG, "Unable to find Google Play Store (com.android.vending)");
return;
}
if (this.initialized)
return;