簡體   English   中英

應用內結算:購買后如何查詢庫存,以獲取價格和貨幣代碼?

[英]In-App Billing: How to query the inventory after purchase, in order to get the price and currency code?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM