我正在使用Google Play结算库进行IAP。它的工作正常,但价格查询除外。
这是查询库存时返回JSON的样子(从logcat检索的日志):
Got sku details:
SkuDetails:{
"title":"Remove ads",
"price":"1,10┬áÔé¼",
"type":"inapp",
"description":"No more ads",
"price_amount_micros":890000,
"price_currency_code":"EUR",
"productId":"remove_ads"
}
当我使用getPrice()
检索本地化价格时,它看起来像这样:1,10┬á?
我在onCreate()
iap_helper = new IabHelper(this, app_key);
iap_helper.enableDebugLogging(true);
iap_helper.startSetup(this);
然后在onIabSetupFinished
我打电话
iap_helper.queryInventoryAsync(this);
答案 0 :(得分:0)
检查以下链接,它对我有用:
http://developer.android.com/training/in-app-billing/list-iab-products.html#QueryDetails
申请库存时,您尚未传递产品ID。我认为如果你在申请库存时没有通过sku_product,那将会给出随机价格,因为没有获得特定产品的响应。
列出additionalSkuList = new List(); //你可以拿数组列表 而不确定它是否正常工作。
additionalSkuList.add(SKU_APPLE);
additionalSkuList.add(SKU_BANANA);iap_helper.queryInventoryAsync(true,additionalSkuList,
mQueryFinishedListener);
IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
if (result.isFailure()) {
// handle error
return;
}
String applePrice =
inventory.getSkuDetails(SKU_APPLE).getPrice();
String bananaPrice =
inventory.getSkuDetails(SKU_BANANA).getPrice();
// update the UI
}
}
希望它能解决你的问题。