在为Android设置新的应用内购买流程时,Google Developer网站上的示例代码说要使用以下片段。
https:/developer.android.comgoogleplaybillingbilling_library_overview。
if (result.getResponseCode() == BillingResponse.OK && skuDetailsList != null) {
for (SkuDetails skuDetails : skuDetailsList) {
String sku = skuDetails.getSku();
String price = skuDetails.getPrice();
if ("premium_upgrade".equals(sku)) {
premiumUpgradePrice = price;
} else if ("gas".equals(sku)) {
gasPrice = price;
}
}
}
然而, BillingResponse.OK
不存在的。如何才能让这个功能发挥作用?
看起来像是重构器改变了这个响应代码的位置,请尝试使用下面的代码来代替:https/eveloper.android.comgoogleplaybilling...。试着用这个来代替。
if (result.getResponseCode() == BillingClient.BillingResponseCode.OK && skuDetailsList != null) {
for (SkuDetails skuDetails : skuDetailsList) {
String sku = skuDetails.getSku();
String price = skuDetails.getPrice();
if ("premium_upgrade".equals(sku)) {
premiumUpgradePrice = price;
} else if ("gas".equals(sku)) {
gasPrice = price;
}
}
}
BillingResponseCode.OK现在在文档中的位置。https:/developer.android.comreferencecomandroidbillingclientapiBillingClient.BillingResponse#OK。