Merge pull request #19 from defold/Issue-3-handle-missing-google-play-store

Handle missing google play store
This commit is contained in:
Björn Ritzl 2020-03-09 11:43:28 +01:00 committed by GitHub
commit 4efe0c2a25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@ -155,10 +156,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;

View File

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

View File

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