我正在尝试验证商店是否购买了产品。
为此,我使用了以下代码:
mHelper.queryInventoryAsync(mGotInventoryListener);
回拨如下所述:
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
// Is it a failure?
**if (result.isFailure()) { // This fails in our case**
complain("Failed to query inventory: " + result);
return;
}
}
};
但每次我收到相同的错误,如下面的附加屏幕所示。
我尝试了下面提到的步骤但未能取得成功。
任何人都可以提出同样的建议。如果我需要添加一些东西来解决这个问题,请告诉我?
答案 0 :(得分:1)
您是否尝试购买 android.test.purchased 或其他商品?如果您使用的是android.test.purchased,请查看此答案,它应该回答您的问题:Android in app purchase: Signature verification failed
答案 1 :(得分:1)
找到解决方案:)
注册广播接收器时出现问题。
请在下面找到 startSetup 方法的代码,该方法正在注册以下代码段中缺少的广播接收器。
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result);
} mBroadcastReceiver = new IabBroadcastReceiver(MainActivity.this);
IntentFilter broadcastFilter = new IntentFilter(IabBroadcastReceiver.ACTION);
registerReceiver(mBroadcastReceiver, broadcastFilter);
// Hooray, IAB is fully set up! }});