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; 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() { private void init() {
// NOTE: We must create Handler lazily as construction of // NOTE: We must create Handler lazily as construction of
// handlers must be in the context of a "looper" on Android // 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) if (this.initialized)
return; return;

View File

@ -11,7 +11,7 @@ height = 1136
[android] [android]
input_method = HiddenInputField input_method = HiddenInputField
package = com.defold.extension.iap package = com.defold.extension.iap
version_code = 3 version_code = 5
[project] [project]
title = extension-iap title = extension-iap

View File

@ -12,6 +12,7 @@ local items = {
SUBSCRIPTION, SUBSCRIPTION,
} }
-- mapping between product id and button name
local item_buttons = { local item_buttons = {
[GOLDBARS_SMALL] = "goldbars_small", [GOLDBARS_SMALL] = "goldbars_small",
[GOLDBARS_MEDIUM] = "goldbars_medium", [GOLDBARS_MEDIUM] = "goldbars_medium",