• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Purchase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.billingclient.api.Purchase的典型用法代码示例。如果您正苦于以下问题:Java Purchase类的具体用法?Java Purchase怎么用?Java Purchase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Purchase类属于com.android.billingclient.api包,在下文中一共展示了Purchase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) {
    if (responseCode == BillingClient.BillingResponse.OK && purchases != null) {
        for (Purchase purchase : purchases) {
            handlePurchase(purchase);
        }
        listener.onPurchasesUpdated(purchases);
    } else if (responseCode == BillingClient.BillingResponse.USER_CANCELED) {
        // Handle an error caused by a user canceling the purchase flow.
        Log.i(TAG, "User canceled.");
    } else {
        // Handle any other error codes.
        Log.i(TAG, "Unknown error. Response code: " + responseCode);
    }
}
 
开发者ID:steevp,项目名称:UpdogFarmer,代码行数:16,代码来源:BillingManager.java


示例2: onResume

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
protected void onResume() {
  super.onResume();
  billingClient = new BillingClient.Builder(this).setListener(this).build();
  billingClient.startConnection(
      new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@BillingResponse int billingResponseCode) {
          if (billingResponseCode == BillingResponse.OK) {
            Purchase.PurchasesResult purchasesResult =
                billingClient.queryPurchases(BillingClient.SkuType.INAPP);
            onPurchasesUpdated(
                purchasesResult.getResponseCode(), purchasesResult.getPurchasesList());
          }
        }

        @Override
        public void onBillingServiceDisconnected() {}
      });
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:21,代码来源:MainActivity.java


示例3: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
public void onPurchasesUpdated(int responseCode, List<Purchase> purchases) {
  if (responseCode != BillingResponse.OK) {
    purchaseFailed();
  } else if (purchases != null) {
    for (Purchase purchase : purchases) {
      if (purchase.getSku().equals(REMOVE_ADS_SKU)) {
        RelativeLayout parent = (RelativeLayout) adView.getParent();
        if (parent != null) {
          parent.removeView(adView);
        }
        this.invalidateOptionsMenu();
        this.adsRemoved = true;
        SharedPreferences.Editor editor = application.getSharedPreferences().edit();
        editor.putBoolean(REMOVE_ADS_SKU, true);
        editor.apply();
      }
    }
  }
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:21,代码来源:MainActivity.java


示例4: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
public void onPurchasesUpdated(List<Purchase> purchases) {
    if (!billingManager.shouldDisplayAds()) {
        removeAds();
        drawerView.getMenu().findItem(R.id.remove_ads).setVisible(false);
    }
}
 
开发者ID:steevp,项目名称:UpdogFarmer,代码行数:8,代码来源:MainActivity.java


示例5: queryPurchases

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
private void queryPurchases() {
    final Purchase.PurchasesResult result = billingClient.queryPurchases(BillingClient.SkuType.INAPP);
    final List<Purchase> purchases = result.getPurchasesList();
    if (purchases != null) {
        for (Purchase purchase : purchases) {
            handlePurchase(purchase);
        }
    }
}
 
开发者ID:steevp,项目名称:UpdogFarmer,代码行数:10,代码来源:BillingManager.java


示例6: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
/**
 * After google payment successfully get response
 * @param purchaseList successful payment receive response
 */

@Override
public void onPurchasesUpdated(List<Purchase> purchaseList) {

    for (Purchase purchase : purchaseList) {
        if (Objects.equals(purchase.getSku(), SKU_ID)) {
            mActivity.onPurchasesUpdated(purchaseList);
            break;
        }
    }
}
 
开发者ID:uthayacloud,项目名称:AndroidInAppBilling,代码行数:16,代码来源:InAPPBillingSetup.java


示例7: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
/**
 * After google payment successfully get response
 * @param purchaseList successful payment receive response
 */

void onPurchasesUpdated(List<Purchase> purchaseList) {
    Intent resultIntent = new Intent();
    Bundle args = new Bundle();
    args.putSerializable("result", (Serializable) purchaseList);
    resultIntent.putExtra("PurchaseBundle", args);
    activity.setResult(Activity.RESULT_OK, resultIntent);
    activity.finish();
}
 
开发者ID:uthayacloud,项目名称:AndroidInAppBilling,代码行数:14,代码来源:HomeActivity.java


示例8: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
/**
 * Handle a callback that purchases were updated from the Billing library
 */
@Override
public void onPurchasesUpdated(int resultCode, List<Purchase> purchases) {
    if (resultCode == BillingResponse.OK) {
        for (Purchase purchase : purchases) {
            handlePurchase(purchase);
        }
        mBillingUpdatesListener.onPurchasesUpdated(mPurchases);
    } else if (resultCode == BillingResponse.USER_CANCELED) {
        Log.i(TAG, "onPurchasesUpdated() - user cancelled the purchase flow - skipping");
    } else {
        Log.w(TAG, "onPurchasesUpdated() got unknown resultCode: " + resultCode);
    }
}
 
开发者ID:uthayacloud,项目名称:AndroidInAppBilling,代码行数:17,代码来源:BillingManager.java


示例9: handlePurchase

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
/**
 * Handles the purchase
 * <p>Note: Notice that for each purchase, we check if signature is valid on the client.
 * It's recommended to move this check into your backend.
 * See {@link Security#verifyPurchase(String, String, String)}
 * </p>
 * @param purchase Purchase to be handled
 */
private void handlePurchase(Purchase purchase) {
    if (!verifyValidSignature(purchase.getOriginalJson(), purchase.getSignature())) {
        Log.i(TAG, "Got a purchase: " + purchase + "; but signature is bad. Skipping...");
        return;
    }

    Log.d(TAG, "Got a verified purchase: " + purchase);

    mPurchases.add(purchase);
}
 
开发者ID:uthayacloud,项目名称:AndroidInAppBilling,代码行数:19,代码来源:BillingManager.java


示例10: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
/**
 * Handle a callback that purchases were updated from the Billing library
 */
@Override
public void onPurchasesUpdated(int resultCode, List<Purchase> purchases) {
    if (resultCode == BillingResponse.OK) {
        for (Purchase purchase : purchases) {
            handlePurchase(purchase);
        }
        billingUpdatesListener.onPurchasesUpdated(this.purchases);
    } else if (resultCode == BillingResponse.USER_CANCELED) {
        Log.i(TAG, "onPurchasesUpdated() - user cancelled the purchase flow - skipping");
    } else {
        Log.w(TAG, "onPurchasesUpdated() got unknown resultCode: " + resultCode);
    }
}
 
开发者ID:plusCubed,项目名称:velociraptor,代码行数:17,代码来源:BillingManager.java


示例11: handlePurchase

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
/**
 * Handles the purchase
 * <p>Note: Notice that for each purchase, we check if signature is valid on the client.
 * It's recommended to move this check into your backend.
 * See {@link Security#verifyPurchase(String, String, String)}
 * </p>
 *
 * @param purchase Purchase to be handled
 */
private void handlePurchase(Purchase purchase) {
    if (!verifyValidSignature(purchase.getOriginalJson(), purchase.getSignature())) {
        Log.i(TAG, "Got a purchase: " + purchase + "; but signature is bad. Skipping...");
        return;
    }

    Log.d(TAG, "Got a verified purchase: " + purchase);

    purchases.add(purchase);
}
 
开发者ID:plusCubed,项目名称:velociraptor,代码行数:20,代码来源:BillingManager.java


示例12: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
public void onPurchasesUpdated(@BillingClient.BillingResponse int responseCode, List<Purchase> purchases) {
    if (responseCode == BillingClient.BillingResponse.OK && purchases != null) {
        if(getView() != null) {
            // Apply preference
            SharedPreferences settings = getActivity().getSharedPreferences(PREFS_NAME, 0);
            SharedPreferences.Editor editor = settings.edit();
            editor.putBoolean("donationPurchased", true);
            editor.apply();

            // Destroy Ad
            AdView mAdView = getActivity().findViewById(R.id.adView);
            mAdView.setVisibility(GONE);
            mAdView.destroy();

            showDonatorStatus();
        }
    } else if (responseCode == BillingClient.BillingResponse.USER_CANCELED) {
        // Handle an error caused by a user cancelling the purchase flow.
        if(getView() != null) {
            Snackbar.make(getView(), R.string.donation_cancelled, Snackbar.LENGTH_SHORT).show();
        }
    } else {
        // Handle any other error codes.
        if(getView() != null) {
            Snackbar.make(getView(), R.string.donation_cancelled, Snackbar.LENGTH_SHORT).show();
        }
    }
}
 
开发者ID:systemallica,项目名称:ValenBisi,代码行数:30,代码来源:DonateFragment.java


示例13: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
public void onPurchasesUpdated(@BillingClient.BillingResponse int responseCode, List<Purchase> purchases) {
    //if (responseCode == BillingClient.BillingResponse.OK && purchases != null) {
        // Success
    //} else if (responseCode == BillingClient.BillingResponse.USER_CANCELED) {
        // Handle an error caused by a user cancelling the purchase flow.
    //} else {
        // Handle any other error codes.
    //}
}
 
开发者ID:systemallica,项目名称:ValenBisi,代码行数:11,代码来源:MainActivity.java


示例14: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
public void onPurchasesUpdated(List<Purchase> purchaseList) {
    mGoldMonthly = false;
    mGoldYearly = false;

    for (Purchase purchase : purchaseList) {
        switch (purchase.getSku()) {
            case PremiumDelegate.SKU_ID:
                Log.d(TAG, "You are Premium! Congratulations!!!");
                mIsPremium = true;
                break;
            case GasDelegate.SKU_ID:
                Log.d(TAG, "We have gas. Consuming it.");
                // We should consume the purchase and fill up the tank once it was consumed
                mActivity.getBillingManager().consumeAsync(purchase.getPurchaseToken());
                break;
            case GoldMonthlyDelegate.SKU_ID:
                mGoldMonthly = true;
                break;
            case GoldYearlyDelegate.SKU_ID:
                mGoldYearly = true;
                break;
        }
    }

    mActivity.showRefreshedUi();
}
 
开发者ID:googlesamples,项目名称:android-play-billing,代码行数:28,代码来源:MainViewController.java


示例15: onQueryInventoryFinished

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
public void onQueryInventoryFinished(IabResult result, Inventory inv) {
    isPro = (inv.hasPurchase(SKU_UPGRADE) &&
            inv.getPurchase(SKU_UPGRADE).getPurchaseState() == Purchase.PurchaseState.PURCHASED);
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:6,代码来源:CustomIABHelper.java


示例16: isOrderOk

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
public static boolean isOrderOk(IabResult result, Inventory inv) {
    return result.getResponse() == IabHelper.BILLING_RESPONSE_RESULT_OK &&
            inv.hasPurchase(SKU_UPGRADE) &&
            (inv.getPurchase(SKU_UPGRADE).getPurchaseState() == Purchase.PurchaseState.PURCHASED);
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:6,代码来源:CustomIABHelper.java


示例17: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
public void onPurchasesUpdated(int responseCode, List<Purchase> purchases) {
    Log.i(TAG, "onPurchasesUpdated() response: " + responseCode);
}
 
开发者ID:googlecodelabs,项目名称:play-billing-codelab,代码行数:5,代码来源:BillingManager.java


示例18: onPurchasesUpdated

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
@Override
public void onPurchasesUpdated(@BillingResponse int responseCode, List<Purchase> purchases) {
    Log.i(TAG, "onPurchasesUpdated() response: " + responseCode);
}
 
开发者ID:googlecodelabs,项目名称:play-billing-codelab,代码行数:5,代码来源:BillingManager.java


示例19: handlePurchase

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
private void handlePurchase(Purchase purchase) {
    if ("remove_ads".equals(purchase.getSku())) {
        displayAds = false;
    }
}
 
开发者ID:steevp,项目名称:UpdogFarmer,代码行数:6,代码来源:BillingManager.java


示例20: verifyRaptorService

import com.android.billingclient.api.Purchase; //导入依赖的package包/类
public void verifyRaptorService(Purchase purchase) {
    raptorLimitProvider.verify(purchase);
}
 
开发者ID:plusCubed,项目名称:velociraptor,代码行数:4,代码来源:LimitFetcher.java



注:本文中的com.android.billingclient.api.Purchase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AmazonIdentityManagementClientBuilder类代码示例发布时间:2022-05-22
下一篇:
Java ContainerStopMonitoringEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap