如何查询(价格)信息的多应用内商品一次? [英] How to query (price) information for multiple in-app products at once?

查看:123
本文介绍了如何查询(价格)信息的多应用内商品一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的应用程序中的计费是否有可能以某种方式查询(价格)信息使用一个查询所有的产品?最理想的,你可以通过在产品ID,它会返回信息的。

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.

我正在寻找的是SKProductsRequest相当于Android Market的。 <一href="http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKProductsRequest/Reference/Reference.html#//apple_ref/occ/cl/SKProductsRequest">http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKProductsRequest/Reference/Reference.html#//apple_ref/occ/cl/SKProductsRequest

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

推荐答案

现在有可能与计费API第3版。你可以用<一个信息href="https://developer.android.com/google/play/billing/billing_reference.html#getSkuDetails"><$c$c>getSkuDetails()方法。示例是<一个href="https://developer.android.com/google/play/billing/billing_integrate.html#QueryDetails">here.

It is possible now with Billing API v3. You can get information with getSkuDetails() method. Example is here.

ArrayList skuList = new ArrayList();
skuList.add("premiumUpgrade"); 
skuList.add("gas");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);

Bundle skuDetails = mService.getSkuDetails(3, getPackageName(), "inapp", querySkus);

int response = skuDetails.getInt("RESPONSE_CODE");
if (response == 0) {
    ArrayList responseList = skuDetails.getStringArrayList("DETAILS_LIST");

    for (String thisResponse : responseList) {
        JSONObject object = new JSONObject(thisResponse);
        String sku = object.getString("productId");
        String price = object.getString("price");
        if (sku.equals("premiumUpgrade")) {
            mPremiumUpgradePrice = price;
        } else if (sku.equals("gas")) { 
            mGasPrice = price;
        }
    }
}

这篇关于如何查询(价格)信息的多应用内商品一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆