我正在尝试在应用购买中实施并且已经出现问题好几天了。当用户尝试进行购买时,它是成功的,但应用程序发出一个奇怪的错误,显然可以追溯到os build bee,这会阻止用户在再次点击购买按钮之前收到购买。
步骤:
购买
成功购买
没有消耗品
再次点击购买按钮
消耗品
以下是未给出消耗品时出现的错误:
日志标记:Finsky
日志消息[1] 1.run:缺少inapp的传递数据:com.mybillingproblem:one_chip
PID / TID:26927
代码:
public void oneChip(String noVal) {
Log.v("oneChip", "Calling launch purchase flow");
bp.purchase(this, itemOne);
Log.v("oneChip", "made it through launch purchase flow");
}
bp = new BillingProcessor(this, base64EncodedPublicKey,
new BillingProcessor.IBillingHandler() {
@Override
public void onBillingInitialized() {
Log.v("chip", "billing initialized");
readyToPurchase = true;
}
@Override
public void onProductPurchased(String productId,
TransactionDetails details) {
Log.v("chip", productId + " purchased");
if (bp.consumePurchase(productId)) {
if (productId == "itemOne"
|| productId == "one_chip")
ChipUpdate.updateChipCount(2500);
}
}
@Override
public void onBillingError(int errorCode, Throwable error) {
Log.v("chip", "Error code: " + errorCode);
Log.v("chip", "Error: " + error);
}
@Override
public void onPurchaseHistoryRestored() {
for (String sku : bp.listOwnedProducts())
Log.v("chip", "Owned Managed Product: " + sku);
for (String sku : bp.listOwnedSubscriptions())
Log.v("chip", "Owned Subscription: " + sku);
}
});
注意:我正在使用in app billing v3 jar。我不认为这是问题,因为它已被推荐并且似乎是一种常用的包装器。
谢谢!
答案 0 :(得分:1)
您的Activity的onActivityResult()如何?你是否有一个? 通常您将结果传递给IabHelper的handleActivityResult
像这样:@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
// Pass on the activity result to the iab helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data))
{
// not handled, so handle it ourselves (here's where you'd
// perform any handling of activity results not related to in-app
// billing...
super.onActivityResult(requestCode, resultCode, data);
}
}