问题可能由于缓存造成,可以尝试清除缓存并重新查询SkuDetails信息:
private BillingClient billingClient;
private Map skuDetailsMap = new HashMap<>();
public void clearSkuDetailsCache() {
skuDetailsMap.clear();
}
public void querySkuDetails(final List skuList, SkuDetailsResponseListener listener) {
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP);
billingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(BillingResult billingResult, List skuDetailsList) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
for (SkuDetails skuDetails : skuDetailsList) {
skuDetailsMap.put(skuDetails.getSku(), skuDetails);
}
}
listener.onSkuDetailsResponse(billingResult, skuDetailsList);
}
});
}
public SkuDetails getSkuDetails(String sku) {
return skuDetailsMap.get(sku);
}