|
|
@ -68,8 +68,9 @@ import java.util.Arrays;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class ActivityBilling extends ActivityBase
|
|
|
|
public class ActivityBilling extends ActivityBase implements
|
|
|
|
implements /*PurchasesUpdatedListener, BillingClientStateListener,*/ FragmentManager.OnBackStackChangedListener {
|
|
|
|
/* BillingClientStateListener, SkuDetailsResponseListener, PurchasesResponseListener, PurchasesUpdatedListener, */
|
|
|
|
|
|
|
|
FragmentManager.OnBackStackChangedListener {
|
|
|
|
private boolean standalone = false;
|
|
|
|
private boolean standalone = false;
|
|
|
|
private int backoff = 4; // seconds
|
|
|
|
private int backoff = 4; // seconds
|
|
|
|
//private BillingClient billingClient = null;
|
|
|
|
//private BillingClient billingClient = null;
|
|
|
@ -354,16 +355,15 @@ public class ActivityBilling extends ActivityBase
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void queryPurchases() {
|
|
|
|
private void queryPurchases() {
|
|
|
|
billingClient.queryPurchasesAsync(BillingClient.SkuType.INAPP, new PurchasesResponseListener() {
|
|
|
|
billingClient.queryPurchasesAsync(BillingClient.SkuType.INAPP, this);
|
|
|
|
@Override
|
|
|
|
}
|
|
|
|
public void onQueryPurchasesResponse(@NonNull BillingResult result, @NonNull List<Purchase> list) {
|
|
|
|
|
|
|
|
if (result.getResponseCode() == BillingClient.BillingResponseCode.OK)
|
|
|
|
|
|
|
|
checkPurchases(list);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
reportError(result, "IAB query purchases");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
});
|
|
|
|
public void onQueryPurchasesResponse(@NonNull BillingResult result, @NonNull List<Purchase> list) {
|
|
|
|
|
|
|
|
if (result.getResponseCode() == BillingClient.BillingResponseCode.OK)
|
|
|
|
|
|
|
|
checkPurchases(list);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
reportError(result, "IAB query purchases");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
interface IBillingListener {
|
|
|
|
interface IBillingListener {
|
|
|
@ -479,20 +479,19 @@ public class ActivityBilling extends ActivityBase
|
|
|
|
SkuDetailsParams.Builder builder = SkuDetailsParams.newBuilder();
|
|
|
|
SkuDetailsParams.Builder builder = SkuDetailsParams.newBuilder();
|
|
|
|
builder.setSkusList(query);
|
|
|
|
builder.setSkusList(query);
|
|
|
|
builder.setType(BillingClient.SkuType.INAPP);
|
|
|
|
builder.setType(BillingClient.SkuType.INAPP);
|
|
|
|
billingClient.querySkuDetailsAsync(builder.build(),
|
|
|
|
billingClient.querySkuDetailsAsync(builder.build(), this);
|
|
|
|
new SkuDetailsResponseListener() {
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onSkuDetailsResponse(@NonNull BillingResult result, List<SkuDetails> skuDetailsList) {
|
|
|
|
@Override
|
|
|
|
if (result.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
|
|
|
public void onSkuDetailsResponse(@NonNull BillingResult result, List<SkuDetails> skuDetailsList) {
|
|
|
|
for (SkuDetails skuDetail : skuDetailsList) {
|
|
|
|
if (result.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
|
|
|
Log.i("IAB SKU detail=" + skuDetail);
|
|
|
|
for (SkuDetails skuDetail : skuDetailsList) {
|
|
|
|
for (IBillingListener listener : listeners)
|
|
|
|
Log.i("IAB SKU detail=" + skuDetail);
|
|
|
|
listener.onSkuDetails(skuDetail.getSku(), skuDetail.getPrice());
|
|
|
|
for (IBillingListener listener : listeners)
|
|
|
|
}
|
|
|
|
listener.onSkuDetails(skuDetail.getSku(), skuDetail.getPrice());
|
|
|
|
} else
|
|
|
|
}
|
|
|
|
reportError(result, "IAB query SKUs");
|
|
|
|
} else
|
|
|
|
}
|
|
|
|
reportError(result, "IAB query SKUs");
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void consumePurchase(final Purchase purchase) {
|
|
|
|
private void consumePurchase(final Purchase purchase) {
|
|
|
|