本文介绍了谷歌应用程式内结算的空异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个空的异常错误,当我查询了谷歌应用程式内结算项目的产品上市。

I am getting a Null Exception error when I query the Product listing for a Google InApp Billing item.

我有一个项目添加到应用内的开发者控制台网站,它的状态显示为活动;

I have one item added to the In-App Developer Console website and it shows the status as "Active";

下面是我的code。

 // Listener that's called when we finish querying the items and subscriptions we own
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
    public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
        Log.d(TAG, "Query inventory finished 15.");
        if (result.isFailure()) {
           Log.d(TAG,"Failed to query inventory: " + result);
            return;
        }

        SkuDetails productDetails = inventory.getSkuDetails(SKU_ANATVITALSIGNS);

  //      Log.d(TAG,"Gas Price is: " + productDetails.getPrice());

        if (productDetails != null){
            Log.d(TAG,"Deck price is: " + productDetails.getPrice());
        }else{

            Log.d(TAG,"No Product Detail" );
        }

        Log.d(TAG, "Query inventory was successful.");

//        updateUi();
//        setWaitScreen(false);
        Log.d(TAG, "Initial inventory query finished; enabling main UI.");
    }

程序错误,当我试图让productDetails.getPrice()为例。

The program errors when I try to get "productDetails.getPrice()" for example.

任何帮助是AP preciated。这是一个为期两天的头爆竹。

Any help is appreciated. This has been a two-day head banger.

TIA

推荐答案

我没有打电话与格式正确的查询监听器。

I was not calling the listener with the correctly formatted inquire.

我添加下面的code和传递的信息给听者,现在我的产品的细节显示出来。

I added the code below and passed the information to the listener and my product details are now showing up.

下面是code我改变:

Below is the code I changed:

String[] moreSkus = {SKU_ANATVITALSIGNS};
mHelper.queryInventoryAsync(true, Arrays.asList(moreSkus), mGotInventoryListener);

这解决了这一问题。

这篇关于谷歌应用程式内结算的空异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:15