从计费库4.0迁移到5.0时,我无法检查购买状态。
billingClient.queryPurchasesAsync(QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.INAPP).build(), new PurchasesResponseListener() {
@Override
public void onQueryPurchasesResponse(@NonNull BillingResult billingResult, @NonNull List<Purchase> list) {
if(billingResult.getResponseCode() == RESULT_OK && list != null){
Toast.makeText(getApplicationContext(),"purchase is done", Toast.LENGTH_LONG).show();
}
else if(billingResult.getResponseCode() == RESULT_CANCELED && list == null){
Toast.makeText(getApplicationContext(),"purchase not done", Toast.LENGTH_LONG).show();
}
}
});
2条答案
按热度按时间wlp8pajw1#
调用queryPurchasesAsync返回以下响应(转换为字符串表示)
这里的键purchaseState告诉您的购买状态。您可以从下面的链接here参考更多关于购买状态的详细信息
0x6upsns2#
您的billingClient未初始化。