Android IAB V3 查询拥有的项目返回正数但在消费时返回不拥有的项目

标签 android in-app-billing

我在我的应用程序中实现了 android IAB V3。在购买和消费元素后立即查询拥有的元素时,IABHelper 返回我仍然拥有该元素。但是在调用 consume 时它返回该项目不被拥有。我在下面给出了我的 logcat 输出。

04-19 15:57:43.668: D/IabHelper(2757): Starting async operation: refresh inventory
04-19 15:57:43.678: D/IabHelper(2757): Querying owned items...
04-19 15:57:43.688: D/IabHelper(2757): Package name: com.games.mygame
04-19 15:57:43.688: D/IabHelper(2757): Calling getPurchases with continuation token: null
04-19 15:57:43.728: D/IabHelper(2757): Owned items response: 0
04-19 15:57:43.758: D/IabHelper(2757): Sku is owned: com.games.pack1
04-19 15:57:43.768: D/IabHelper(2757): Continuation token: null
04-19 15:57:43.768: D/IabHelper(2757): Querying SKU details.
04-19 15:57:43.838: D/IabHelper(2757): Got sku details: SkuDetails:{"title":"Coin Pack 1 (My Game)","price":"Rs. 105.69","type":"inapp","description":"Pack of 50000 coins.","productId":"com.games.pack1"}
04-19 15:57:43.838: D/IabHelper(2757): Ending async operation: refresh inventory
04-19 15:57:46.931: D/IabHelper(2757): Ending async operation: 
04-19 15:57:46.931: D/IabHelper(2757): Starting async operation: consume
04-19 15:57:46.931: D/IabHelper(2757): Consuming sku: com.games.pack1, token: wykaaffjpwmehhfdkgmzsbpb.AO-J1OxWZjidethjntgfks3C1tpo6TfiMgWyAc8ycTZWsr7UcaHidKIFRaH-K6L_aa2SYGFc3mq8kLBVajj3mtXQcw8oy8-GAT8aSBLJA_aP3AsnjEKSQ1Ot0OqTBDKJWRduiz
04-19 15:57:47.642: D/IabHelper(2757): Error consuming consuming sku com.games.pack1. 8:Item not owned
04-19 15:57:47.642: D/IabHelper(2757): Ending async operation: consume

我必须等待几分钟才能再次购买该商品。这是因为 google play 的本地缓存。以前有没有人遇到过这个问题。谁能告诉我可能出了什么问题以及如何解决。

最佳答案

好吧,答案在应用内计费文档中 http://developer.android.com/google/play/billing/api.html#consume

这是由本地缓存引起的。 由于 Google Play 客户端现在在设备本地缓存应用内结算信息,您可以使用第 3 版 API 更频繁地查询此信息,例如通过 getPurchases 调用。与以前版本的 API 不同,许多第 3 版 API 调用将通过缓存查找而不是通过网络连接到 Google Play 来提供服务,这显着加快了 API 的响应时间。这就是为什么他们建议根据消费函数的响应而不是根据拥有的元素来奖励购买的元素。

关于Android IAB V3 查询拥有的项目返回正数但在消费时返回不拥有的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16103223/

相关文章:

android - 短信计费安卓

android - CONFIRM_NOTIFICATIONS 消息给出 SERVICE_UNAVAILABLE 结果

android - 如何获取应用内购买的单独价格和货币信息?

java - 如何从 php 文件获取变量并在 Android Activity 中使用它?

android - 如何在 android 5.0 中将 webview 捕获到位图?

java - 尝试从 Android Studio 中的 res->raw 文件夹获取视频 uri 时出现文件未找到异常

android - App purchase android 的收款账号在哪里设置?

返回应用程序时 Android 后台 Activity 消失

Android - 如何在另一个 Activity 期间暂停线程?

Android "The payment method has been declined"每种支付方式