【问题标题】:I want to check if the item is purchased before, v4 In-App billing我想检查该项目是否以前购买过,v4 应用内计费
【发布时间】:2022-12-28 18:54:45
【问题描述】:

我有一件一次性的非消耗品。我想在启动购买流程之前检查商品是否已经购买。我尝试了很多东西,但没有任何效果。我搜索了一下,但找不到 v4 的解决方案。你能帮我吗?

       billingClient.queryPurchasesAsync(
                         BillingClient.SkuType.INAPP,
                         new PurchasesResponseListener() {
                             @Override
                             public void onQueryPurchasesResponse(@NonNull BillingResult billingResult, @NonNull List<Purchase> list) {
                                 if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
                                     for (Purchase purchase : list) {

                                         if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) {
                                             //handlePurchase(purchase);
                                             savePurchaseValueToPref(true);
                                         }
                                     }
                                 }
                             }
                         }
                 );

我将此代码放在 onBillingSetupFinished 中,但它没有按我想要的那样工作

【问题讨论】:

  • 请问大佬有解决办法吗,谢谢

标签: android in-app-billing billing android-billing play-billing-library


【解决方案1】:

您可以将标志保存到 sharedPreferences,并检查标志是真还是假以启动购买流程

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-21
    相关资源
    最近更新 更多