I have a program that sets an alert dialog that asks "Would you like to purchase "TITLE" for "PRICE""
I know that the Google IAB library has a getSku() call but that's only available after a result from purchasing the item. Is there a way to get these two variables before any purchasing? Thanks.
I might have seen an item that queries a bundle of sku's which lists out all the items, but I may be wrong
use this method in IABHelper:
List<String> moreSkus = new ArrayList<String>();
moreSkus.add("sku1");
moreSkus.add("sku2");
mHelper.queryInventoryAsync(true, moreSkus, mGotInventoryListener);
I test it works ok ,you can add inapp or sub type sku to list ,and return all details in invenroty
found a solution for this. first of all you will need the sku/product id.
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
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With