我想使用android计费版本5,问题是我使用的是第3版,有些东西现在被废弃了。
我有过这个,但是PurchasesResult,queryPurchases和getPurchasesList已经不存在了:
@Override
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
if(billingResult.getResponseCode()==BillingClient.BillingResponseCode.OK){
Purchase.PurchasesResult queryPurchase = billingClient.queryPurchases(INAPP);
List<Purchase> queryPurchases = queryPurchase.getPurchasesList();
if(queryPurchases!=null && queryPurchases.size()>0){
handlePurchases(queryPurchases);
}我如何使它在第5版上工作呢?
也无法解析getSku():
//if purchase is pending
else if( PRODUCT_ID.equals(purchase.getSku()) && purchase.getPurchaseState() == Purchase.PurchaseState.PENDING)
{
Toast.makeText(getApplicationContext(),
R.string.plus_pending, Toast.LENGTH_SHORT).show();
}谢谢
发布于 2022-11-11 13:58:19
他是Google计费库4到5迁移指南https://developer.android.com/google/play/billing/migrate-gpblv5#processing-purchases
从您的例子来看,我认为您必须调用billingClient.queryPurchasesAsync。而且您不需要再调用queryPurchase.getPurchasesList(),您将收到列表购买作为侦听器参数返回。
billingClient.queryPurchasesAsync(
QueryPurchasesParams.newBuilder().setProductType(ProductType.SUBS).build(),
new PurchasesResponseListener() {
public void onQueryPurchasesResponse(
@NonNull BillingResult billingResult,
@NonNull List<Purchase> purchases) {
// Process the result
if(purchases.size()>0){
handlePurchases(purchases);
}
}
});https://stackoverflow.com/questions/72289150
复制相似问题