In the Google IAB, can I get the title and price of the product before I call the launchpurchaseflow method?

I have a program that sets up a warning dialog box that asks: "You want to buy" TITLE "for" PRICE ""

I know that in the Google IAB library there is a getSku () call, but available only after the itemโ€™s purchase result. Is there any way to get these two variables before buying? Thanks.

I may have seen an element that requests a sku package that lists all the elements, but I may be wrong

+6
source share
2 answers

found a solution for this. First of all, you will need the sku / product identifier.

public void getProductDetails(String sku) throws RemoteException, JSONException { logDebug("getProductDetails - " + sku); ArrayList<String> skuList = new ArrayList<>(); // Add the specific sku skuList.add(sku); if (sku != null) { Bundle querySkus = new Bundle(); querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList); Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), ITEM_TYPE_INAPP, querySkus); ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST); for (String thisResponse : responseList) { SkuDetails d = new SkuDetails(thisResponse); logDebug("Looking at sku details: " + d); purchaseTitle = d.getTitle(); // these are set as variables so you can call them purchasePrice = d.getPrice(); // whenever you want } } } 
+1
source

use this method in an IABHelper:

  List<String> moreSkus = new ArrayList<String>(); moreSkus.add("sku1"); moreSkus.add("sku2"); mHelper.queryInventoryAsync(true, moreSkus, mGotInventoryListener); 

I test that it works fine, you can add inapp or sub type sku to the list and return all data to invenroty

+2
source

All Articles