当我查询 Google InApp Billing 项目的产品列表时,我收到了 Null Exception 错误。
我已将一项添加到应用程序内开发者控制台网站,它的状态显示为“有效”;
下面是我的代码。
// 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()”时程序出错。
感谢任何帮助。这是为期两天的头脑 Storm 。
TIA
最佳答案
我没有使用格式正确的查询来调用监听器。
我添加了下面的代码并将信息传递给监听器,我的产品详细信息现在显示出来了。
下面是我修改的代码:
String[] moreSkus = {SKU_ANATVITALSIGNS};
mHelper.queryInventoryAsync(true, Arrays.asList(moreSkus), mGotInventoryListener);
这解决了问题。
关于android - Google InApp Billing 空异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15433909/