Prevent crash

pull/147/head
M66B 6 years ago
parent 157bfbdf5a
commit 75e2a2a302

@ -172,6 +172,10 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
public void onBillingSetupFinished(@BillingClient.BillingResponse int responseCode) { public void onBillingSetupFinished(@BillingClient.BillingResponse int responseCode) {
String text = Helper.getBillingResponseText(responseCode); String text = Helper.getBillingResponseText(responseCode);
Log.i(Helper.TAG, "IAB connected response=" + text); Log.i(Helper.TAG, "IAB connected response=" + text);
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
return;
if (responseCode == BillingClient.BillingResponse.OK) { if (responseCode == BillingClient.BillingResponse.OK) {
backoff = 4; backoff = 4;
queryPurchases(); queryPurchases();
@ -186,8 +190,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!billingClient.isReady() && if (!billingClient.isReady())
getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
billingClient.startConnection(billingClientStateListener); billingClient.startConnection(billingClientStateListener);
} }
}, backoff * 1000L); }, backoff * 1000L);

Loading…
Cancel
Save