Android在应用程序内结算:无法启动launchPurchaseFlow因为launchPurchaseFlow正在进行 [英] Android In App Billing: Can't start launchPurchaseFlow because launchPurchaseFlow is in progress
问题描述
我实施在应用程序内结算的第一次和我使用的是静态的SKU IDS测试我第一次购买。
I'm implementing In App Billing for the first time and I'm testing my first purchases using the static SKU ids.
这工作非常出色的第一次。我叫 mHelper.launchPurchaseFlow(...)
并完成了测试购买。我的活动受到了 onActivityResult
回调,我确信与处理它mHelper.handleActivityResult(...)
。一切是伟大的。
It worked very well the first time. I called mHelper.launchPurchaseFlow(...)
and completed the test purchase. My activity received the onActivityResult
callback and I made sure to process it with mHelper.handleActivityResult(...)
. Everything was great.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Pass on the activity result to the helper for handling
log("onActivityResult");
if (!this.mHelper.handleActivityResult(requestCode, resultCode, data)) {
log("cleared the launch flow");
// 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);
}
}
不过,我想测试下一部分,所以我重新启动应用程序,并试图购买同一SKU(静态购买
SKU)。
mHelper.launchPurchaseFlow(rootActivity, "android.test.purchased", 10002,
new IabHelper.OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase purchaseInfo) {
if (result.isFailure()) {
log("purchased failed");
} else {
log("purchase succeeded");
}
}
}, "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
我第二次尝试购买该项目,我的 OnIabPurchaseFinishedListener
叫我看购买失败
在我日志:应用内计费错误:无法购买物品,错误响应:7:项目已经拥有了
The second time I try to purchase the item, my OnIabPurchaseFinishedListener
is called and I see purchase failed
in my log: "In-app billing error: Unable to buy item, Error response: 7:Item Already Owned"
这是有道理的,但如果我尝试购买其他项目,那么我的应用程序崩溃,出现以下错误:
That makes sense, but if I try to purchase another item, then my app crashes with the following error:
java.lang.IllegalStateException:无法启动异步操作 (launchPurchaseFlow)因为另一个异步 操作(launchPurchaseFlow)正在进行中。
java.lang.IllegalStateException: Can't start async operation (launchPurchaseFlow) because another async operation(launchPurchaseFlow) is in progress.
当我尝试这样做,无法购买 onActivityResult
回调不会发生,所以没有推出流没有得到处理,并清理。所以,当我尝试另一种购买,这就是为什么它会崩溃,因为它仍然是所谓的最后失败的事务处理过程中。
The onActivityResult
callback doesn't happen when I try to do the purchase that fails, so the launch flow that failed doesn't get handled and cleaned up. So, when I try another purchase, that's why it crashes because it's still supposedly in the middle of the last failed transaction.
我是什么做错了吗?我如何确保launchPurchaseFlow()是在失败后清理?
What am I doing wrong? How do I ensure that the launchPurchaseFlow() is cleaned up after a failure?
推荐答案
我相信,你只需要拿到C中的应用程序内计费类更新$ C $,你应该不会遇到同样的问题了。
I believe you just have to get the updated code the the in-app billing classes and you shouldn't run into the same problem again.
谷歌尚未推出更改到SDK管理器还因为据我所知。只需复制/粘贴新的类到你的,你应该不会遇到这个问题的任何更长的时间。
Google hasn't pushed out the changes to the SDK Manager yet as far as I know. Just copy/paste the new classes into yours and you shouldn't run into the problem any longer.
有一个在这里的新的code的变化: <一href="https://$c$c.google.com/p/marketbilling/source/detail?r=7ec85a9b619fc5f85023bc8125e7e6b1ab4dd69f&path=/v3/src/com/example/android/trivialdrivesample/MainActivity.java">https://$c$c.google.com/p/marketbilling/source/detail?r=7ec85a9b619fc5f85023bc8125e7e6b1ab4dd69f&path=/v3/src/com/example/android/trivialdrivesample/MainActivity.java
Have a look at the new code changes here: https://code.google.com/p/marketbilling/source/detail?r=7ec85a9b619fc5f85023bc8125e7e6b1ab4dd69f&path=/v3/src/com/example/android/trivialdrivesample/MainActivity.java
这是改变3月15日的课程有:IABHelper.java,Inventory.java,SkuDetails.java以及一些MainActivity.java文件
The classes that were changed as of March 15th are: IABHelper.java, Inventory.java, SkuDetails.java and some of the MainActivity.java file
这篇关于Android在应用程序内结算:无法启动launchPurchaseFlow因为launchPurchaseFlow正在进行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!