queryInventoryAsync上的空指针异常错误

时间:2017-12-12 14:21:32

标签: android nullpointerexception in-app-purchase android-inapp-purchase

从In App Purchase调用以下方法时,我收到空指针异常错误。我在手机上测试过,似乎工作正常。然而,在ANRs&崩溃,我看到人们在这一行上得到空指针异常

inv = queryInventory(querySkuDetails,moreItemSkus,moreSubsSkus);

以下是我在我的应用中使用的IAP示例代码中的代码。

public void queryInventoryAsync(final boolean querySkuDetails, final List<String> moreItemSkus,
        final List<String> moreSubsSkus, final QueryInventoryFinishedListener listener)
    throws IabAsyncInProgressException {
    final Handler handler = new Handler();
    checkNotDisposed();
    checkSetupDone("queryInventory");
    flagStartAsync("refresh inventory");
    (new Thread(new Runnable() {
        public void run() {
            IabResult result = new IabResult(BILLING_RESPONSE_RESULT_OK, "Inventory refresh successful.");
            Inventory inv = null;
            try {
                inv = queryInventory(querySkuDetails, moreItemSkus, moreSubsSkus); // line where null pointer exception is return
            }
            catch (IabException ex) {
                result = ex.getResult();
            }

            flagEndAsync();

            final IabResult result_f = result;
            final Inventory inv_f = inv;
            if (!mDisposed && listener != null) {
                handler.post(new Runnable() {
                    public void run() {
                        listener.onQueryInventoryFinished(result_f, inv_f);
                    }
                });
            }
        }
    })).start();
}

这是我从ANR&amp; amp; amp; amp;崩溃

java.lang.NullPointerException: 
  at com.toksampleapp.util.IabHelper.queryPurchases 
   (IabHelper.java:945)
 at com.toksampleapp.util.IabHelper.queryInventory 
(IabHelper.java:624)
  at com.toksampleapp.util.IabHelper$2.run (IabHelper.java:698)
  at java.lang.Thread.run (Thread.java:818)

0 个答案:

没有答案