在旧版应用内购买中,我通常使用以下代码获取IAP项目的价格。
但是在新版本中,我找不到这样的方法。请帮助我找到在“Google Play结算”中获取所有应用内商品SKU详情的方法。
ArrayList<String> skuList = new ArrayList<String>();
Collections.addAll(skuList, SKU_GEM);
Collections.addAll(skuList, SKU_COMBO);
Collections.addAll(skuList, SKU_SALE);
for(String s : skuList){
Log.d("IabHelper", "skuList from list : " + s);
}
String[][] itemPrice = new String[3][];
itemPrice[0]=new String[SKU_GEM.length];
itemPrice[1]=new String[SKU_COMBO.length];
itemPrice[2]=new String[SKU_SALE.length];
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
Bundle skuDetails = mService.getSkuDetails(3,packageName, "inapp", querySkus);
if (response == 0) {
ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
Log.d("IabHelper", "responseList : " + responseList);
for (String thisResponse : responseList) {
JSONObject object = new JSONObject(thisResponse);
String sku = object.getString("productId");
String price = object.getString("price");
for (int i = 0; i < SKU_GEM.length; i++) {
if(sku.contains(SKU_GEM[i])) {
itemPrice[0][i]=price;
Log.d("IabHelper", "Price of " + SKU_GEM[i] + " " + "itemPrice[0][" + i + "]" + " : " + price);
break;
}
}
for (int i = 0; i < SKU_COMBO.length; i++) {
if(sku.contains(SKU_COMBO[i])) {
itemPrice[1][i]=price;
Log.d("IabHelper", "Price of " + SKU_COMBO[i] + " " + "itemPrice[1][" + i + "]" + " : " + price);
break;
}
}
for (int i = 0; i < SKU_SALE.length; i++) {
if(sku.contains(SKU_SALE[i])) {
itemPrice[2][i]=price;
Log.d("IabHelper", "Price of " + SKU_COMBO[i] + " " + "itemPrice[2][" + i + "]" + " : " + price);
break;
}
}
}