这是我第一次就stackoverflow和一件小事寻求帮助。我当然缺乏理解它的基本知识。如何在handlepurchase(billingclient,purchase)中获得billingclient?提前感谢您的回复
public class Billing {
private Context context;
private List<String> skuList;
' COSTRUTTORE'
public Billing(Context context, List<String> skuList) {
this.context = context;
this.skuList = skuList;
}
' INTERFACCIA CALLBACK '
public interface Callback{
void onSkuDetailsList(BillingClient billingClient, List<SkuDetails> skuDetailsList);
void onResponse(Purchase purchase);
void onError();
}
public void MyPurchase(final Callback callback) {
PurchasesUpdatedListener purchaseUpdateListener = new PurchasesUpdatedListener() {
@Override
public void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && purchases != null) {
for (Purchase purchase : purchases) {
callback.onResponse(purchase);
handlePurchase(billingClient, purchase);
}
} else {
callback.onError();
}
}
};
final BillingClient billingClient = BillingClient.newBuilder(context).enablePendingPurchases().setListener(purchaseUpdateListener).build();
}
static void handlePurchase(BillingClient billingClient, Purchase purchase) {
}
}
1条答案
按热度按时间mwngjboj1#
在顶部添加计费客户端。。。
更换
到
现在billingclient将在