You need to get the price and other in-app details. D IabHelper responseList is empty and does not enter the loop.

for (String thisResponse : responseList) 

I tried different combinations of DETAILS_LIST / ITEM_ID_LIST . Did not help. Tell me, please, how to do it right. Or a link to a good tutorial.

 int querySkuDetails(String ITEM_TYPE_INAPP, Inventory inv, List<String> moreSkus) throws RemoteException, JSONException { logDebug("Querying SKU details."); ArrayList<String> skuList = new ArrayList<String>(); skuList.addAll(inv.getAllOwnedSkus()); if (moreSkus != null) skuList.addAll(moreSkus); if (skuList.size() == 0) { logDebug("queryPrices: nothing to do because there are no SKUs."); return BILLING_RESPONSE_RESULT_OK; } Bundle querySkus = new Bundle(); //querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList); querySkus.putStringArrayList("ITEM_ID_LIST",skuList); Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), ITEM_TYPE_INAPP, querySkus); ArrayList<String> responseList = skuDetails.getStringArrayList( RESPONSE_GET_SKU_DETAILS_LIST); Log.d("Sku skuList",skuList.toString()); Log.d("Sku querySkus",querySkus.toString()); Log.d("Sku skuDetails",skuDetails.toString()); Log.d("Sku responseList"," +"+responseList.isEmpty()); for (String thisResponse : responseList) { SkuDetails d = new SkuDetails(thisResponse); logDebug("Got sku details: " + d); inv.addSkuDetails(d); } return BILLING_RESPONSE_RESULT_OK; } 
  • napp billing does not return data for items you do not request. You are in moreSkus pass ID of the goods for which you want to get info? And in google play your application is published? - lsillarionov

1 answer 1

First you need to create a list of all the goods that you have. For example in OnCreate ():

 additionalSkuList = new ArrayList<String>(); try { additionalSkuList.add("shop_Item1"); additionalSkuList.add("shop_Item2"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } billingInit(); 

Then we do the initialization:

 private void billingInit() { mHelper = new IabHelper(this, BASE64_PUBLIC_KEY); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { return; } // проверяем наши товары, сюда и добавляем наш список additionalSkuList mHelper.queryInventoryAsync(true,additionalSkuList,mGotInventoryListener); } }); } 

Kill two birds with one stone and check whether the goods are purchased and find out the price.

 // Слушатель для востановителя покупок. IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { public void onQueryInventoryFinished(IabResult result, Inventory inventory) { if (result.isFailure()) { return; } try { //узнаем цену всех товаров int price_item_1 = inventory.getSkuDetails("shop_Item1").getPrice(); int price_item_2 = inventory.getSkuDetails("shop_Item2").getPrice(); //Узнаем приобретены ли они Purchase purchase_1 = inventory.getPurchase("shop_Item1"); if (purchase != null && verifyDeveloperPayload(purchase)) { //здесь делаем что-то если этот товар куплен. } Purchase purchase_2 = inventory.getPurchase("shop_Item2"); if (purchase != null && verifyDeveloperPayload(purchase)) { //здесь делаем что-то если этот товар куплен. } } catch (JSONException e) { // TODO Auto-generated catch block Log.d("TWD",e.getMessage()); } } };