应用内结算:如何在购买后查询库存,以获取价格和货币代码?

时间:2017-02-03 19:06:10

标签: android in-app-purchase in-app-billing

我试图在我的Android应用中使用Google应用内结算购买后获取价格和货币代码。

成功购买后,我查询相同SKU的库存但我得到了空白

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();

1 个答案:

答案 0 :(得分:1)