【问题标题】:Currency sign not readable in IAPv3 return JSONIAPv3 中的货币符号不可读返回 JSON
【发布时间】:2023-03-27 15:38:01
【问题描述】:

我正在为 IAP 使用 Google Play 结算库。它工作正常,除了价格查询。

这是查询库存时返回的 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

iap_helper = new IabHelper(this, app_key);
iap_helper.enableDebugLogging(true);
iap_helper.startSetup(this);

然后在onIabSetupFinished我打电话

iap_helper.queryInventoryAsync(this);

【问题讨论】:

  • 检查我下面的答案。

标签: android in-app-billing in-app-purchase android-billing


【解决方案1】:

检查下面的链接,它对我有用:

http://developer.android.com/training/in-app-billing/list-iab-products.html#QueryDetails

您在请求库存时没有传递您的产品 ID。我认为如果您在请求库存时没有通过 sku_product 因为没有得到特定产品进行响应,它会给出随机价格。

List additionalSkuList = new List(); // 你可以取数组列表 而是不确定它是否正常工作。

additionalSkuList.add(SKU_APPLE);
附加SkuList.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   
      }

    }

希望它能解决你的问题。

【讨论】:

  • 如果问题仍然存在,请检查此链接并从 marketbilling 源文件夹更新您的代码。检查此问题:code.google.com/p/marketbilling/issues/… 与您的问题相比似乎相同。让我知道我的回答对你有没有帮助。
  • 不,我是否提供 AdditionalSkuList 没有区别。它在两种情况下都返回正确的 IAP 项目列表,其中包含正确的详细信息,货币符号除外。默认价格在我的开发者控制台中设置为 0.89 欧元,在我的国家/地区设置为 1.10 欧元(含税),因此数值似乎是正确的。只有€(欧元符号)会变成字符垃圾。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-22
  • 2017-06-13
  • 2012-08-12
相关资源
最近更新 更多