Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query (price) information for multiple in-app products at once?

Tags:

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

like image 293
randomguy Avatar asked May 06 '11 14:05

randomguy


1 Answers

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;
        }
    }
}
like image 118
Sergey Glotov Avatar answered Oct 19 '22 19:10

Sergey Glotov