Added IAB connected check

pull/207/head
M66B 3 years ago
parent 9074047eb0
commit bd9c74b8e2

@ -78,8 +78,9 @@ public class ActivityBilling extends ActivityBase implements /*PurchasesUpdatedL
static final String ACTION_PURCHASE_ERROR = BuildConfig.APPLICATION_ID + ".ACTION_PURCHASE_ERROR"; static final String ACTION_PURCHASE_ERROR = BuildConfig.APPLICATION_ID + ".ACTION_PURCHASE_ERROR";
private static final String SKU_TEST = "android.test.purchased"; private static final String SKU_TEST = "android.test.purchased";
private final static long MAX_SKU_CACHE_DURATION = 24 * 3600 * 1000L; // milliseconds private static final long IAB_CONNECTED_CHECK = 10 * 1000L;
private final static long MAX_SKU_NOACK_DURATION = 24 * 3600 * 1000L; // milliseconds private static final long MAX_SKU_CACHE_DURATION = 24 * 3600 * 1000L; // milliseconds
private static final long MAX_SKU_NOACK_DURATION = 24 * 3600 * 1000L; // milliseconds
@Override @Override
@SuppressLint("MissingSuperCall") @SuppressLint("MissingSuperCall")
@ -106,11 +107,26 @@ public class ActivityBilling extends ActivityBase implements /*PurchasesUpdatedL
if (Helper.isPlayStoreInstall() || isTesting(this)) { if (Helper.isPlayStoreInstall() || isTesting(this)) {
Log.i("IAB start"); Log.i("IAB start");
//billingClient = BillingClient.newBuilder(this) /*
// .enablePendingPurchases() billingClient = BillingClient.newBuilder(this)
// .setListener(this) .enablePendingPurchases()
// .build(); .setListener(this)
//billingClient.startConnection(billingClientStateListener); .build();
billingClient.startConnection(billingClientStateListener);
getMainHandler().postDelayed(new Runnable() {
@Override
public void run() {
try {
boolean connected = (billingClient != null &&
billingClient.getConnectionState() == BillingClient.ConnectionState.CONNECTED);
EntityLog.log(ActivityBilling.this, "IAB check connected=" + connected);
} catch (Throwable ex) {
Log.e(ex);
}
}
}, IAB_CONNECTED_CHECK);
*/
} }
} }

@ -78,8 +78,9 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
static final String ACTION_PURCHASE_ERROR = BuildConfig.APPLICATION_ID + ".ACTION_PURCHASE_ERROR"; static final String ACTION_PURCHASE_ERROR = BuildConfig.APPLICATION_ID + ".ACTION_PURCHASE_ERROR";
private static final String SKU_TEST = "android.test.purchased"; private static final String SKU_TEST = "android.test.purchased";
private final static long MAX_SKU_CACHE_DURATION = 24 * 3600 * 1000L; // milliseconds private static final long IAB_CONNECTED_CHECK = 10 * 1000L;
private final static long MAX_SKU_NOACK_DURATION = 24 * 3600 * 1000L; // milliseconds private static final long MAX_SKU_CACHE_DURATION = 24 * 3600 * 1000L; // milliseconds
private static final long MAX_SKU_NOACK_DURATION = 24 * 3600 * 1000L; // milliseconds
@Override @Override
@SuppressLint("MissingSuperCall") @SuppressLint("MissingSuperCall")
@ -111,6 +112,19 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
.setListener(this) .setListener(this)
.build(); .build();
billingClient.startConnection(billingClientStateListener); billingClient.startConnection(billingClientStateListener);
getMainHandler().postDelayed(new Runnable() {
@Override
public void run() {
try {
boolean connected = (billingClient != null &&
billingClient.getConnectionState() == BillingClient.ConnectionState.CONNECTED);
EntityLog.log(ActivityBilling.this, "IAB check connected=" + connected);
} catch (Throwable ex) {
Log.e(ex);
}
}
}, IAB_CONNECTED_CHECK);
} }
} }

Loading…
Cancel
Save