使用计费 API
implementation 'com.android.billingclient:billing:1.1'
使用它来获取 SKU 详细信息
public void getPrices(){
List<String> skuList = new ArrayList<> ();
skuList.add("id_one"); //These are the product ids in your google console
skuList.add("id_two");
skuList.add("id_three");
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP);
mBillingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) {
for (SkuDetails details:
skuDetailsList) {
String item = details.getSku();
String price = details.getPrice();
String description = details.getDescription();
String currencyCode = details.getPriceCurrencyCode();
String title = details.getTitle();
Toast.makeText(InAppBillingActivity.this, "Finished", Toast.LENGTH_SHORT).show();
Log.d("hererereeer- item ", item);
Log.d("hererereeer- price ", price);
Log.d("hererereeer- descr ", description);
Log.d("hererereeer- code ", currencyCode);
Log.d("hererereeer- title ", title);
}
}
});
}