如何一次查询多个应用内商品的(价格)信息?
在 Android 应用程序计费中,是否可以使用一个查询以某种方式查询所有产品的(价格)信息?最好您可以传入产品 ID,它会返回这些信息。
我正在寻找的是 Android Market 的 SKProductsRequest 等效项。 http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKProductsRequest/Reference/Reference.html#//apple_ref/occ/cl/SKProductsRequest
In Android in app billing is it possible to somehow query (price) information for all products using one query? Optimally you could pass in the product IDs and it would return information for those.
What I'm looking for is the SKProductsRequest equivalent for Android Market. http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKProductsRequest/Reference/Reference.html#//apple_ref/occ/cl/SKProductsRequest
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现在可以通过 Billing API v3 实现。您可以使用
getSkuDetails()
< 获取信息/a> 方法。示例如下此处。It is possible now with Billing API v3. You can get information with
getSkuDetails()
method. Example is here.Google 示例片段(例如 https://developer.android.com/ google/play/billing/billing_integrate.html#QueryDetails)和我看到的其他片段不适合我的用法。我需要一个
inventory
实例或一个mHelper
(即 IAB Helper)。看起来问题的赞成票数比接受的答案的赞成票数还要多,所以我并不孤单。我的用法与 TrivialDrive 示例 (https://github.com/TrivialDrive 示例类似)。 com/googlesamples/android-play-billing/blob/master/TrivialDrive/),让我们看一下。在
MainActivity
onCreate
中,有一个对queryInventoryAsync
的调用:在侦听器中,您将拥有库存实例。
我的问题是我的应用内产品是消耗品,我想在开始时查询我的所有产品的详细信息,无论用户是否已经购买了一些产品。例如,我想知道以当地货币而不是美元表示的所有产品的价格,以便用户在进行过多购买之前得到通知。通常
queryInventory
仅返回用户已购买/处理的内容(消费品或非消费品、订阅等)。如果您也有同样的情况(想从一开始就知道所有详细信息),您需要做的有两件事:
mHelper 中调用
您可以在其中进行指示。queryInventoryAsync
的多态变体。 startSetup所以第一个:
这里的第二个参数是产品SKU,第三个参数(我在这里没有使用)是订阅SKU。
第二:然后在
QueryInventoryFinishedListener
中,现在您已将所有这些都包含在inventory
中,并且您可以迭代 SKU:希望这会有所帮助。很快我需要升级到非基于 AIDL 的解决方案。
The Google example snippets (like https://developer.android.com/google/play/billing/billing_integrate.html#QueryDetails) and other snippets I saw did not fit my usage. I either need to have an
inventory
instance or anmHelper
(which is the IAB Helper). Looks like the question's upvote number is bigger than the accepted answer's upvote, so I'm not alone. My usage is similar to the TrivialDrive Example (https://github.com/googlesamples/android-play-billing/blob/master/TrivialDrive/), so let's look at that.In the
MainActivity
onCreate
there's a call forqueryInventoryAsync
:In the listener you gonna have the inventory instance.
My problem is that my in-app products are consumable, and I'd like to query the details for all of my products in the beginning whether the user already bought some or not. For example I want to know the price of all the products expressed in the local currency instead of just USD, so the user is informed before already engaging too much into the purchase. Normally
queryInventory
only gives back what the user already purchased / handled (either consumable or non consumable products, subscriptions, ...).If you are in the same shoes (want to know all details at the start) what you need to do is two fold:
queryInventoryAsync
within themHelper.startSetup
where you can instruct.So the first:
The second parameter here is the product SKUs, the third (I'm not using here) is the subscription SKUs.
Second: Then within the
QueryInventoryFinishedListener
now you have all of them in theinventory
and you can iterate over your SKUs:Hope this helps. Soon I need to upgrade to a non AIDL based solution.