Reputation: 14711
I am trying to obtain the price and the currency code after I've made a purchase using Google In-App Billing in my Android app.
Right after a successful purchase, I query the inventory for the same SKU but I get null
new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
if (result.isFailure()) {
return;
} else if (purchase.getSku().equals(MY_SKU)) {
if (purchase.getPurchaseState() == 0) {
try {
Inventory inventory = appBillingHelper.queryInventory();
price = inventory.getSkuDetails(MY_SKU).getPrice(); // CRASHES WITH A NULL POINTER EXCEPTION for SkuDetails.
currencyCode = inventory.getSkuDetails(MY_SKU).getPriceCurrencyCode();
Upvotes: 0
Views: 876
Reputation: 617
You should follow the steps explained here https://developer.android.com/training/in-app-billing/purchase-iab-products.html#QueryPurchases
Upvotes: 1