Merge pull request #19 from defold/Issue-3-handle-missing-google-play-store
Handle missing google play store
This commit is contained in:
commit
4efe0c2a25
@ -17,6 +17,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@ -155,10 +156,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;
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user