And*_*uin 22 android listener in-app-billing
如果我通过标准发送购买意向
String mySku = "android.test.purchased";
mHelper.launchPurchaseFlow(this, mySku, 10001, mPurchaseFinishedListener);
Run Code Online (Sandbox Code Playgroud)
我能够购买该项目,它将存储,我可以查询该项目,这也很好.唯一不起作用的是PurchaseFinishedListener.我的编码与示例应用程序非常相似,但它似乎根本没有被调用.
12-12 01:40:47.248: D/IabHelper(23502): Calling getPurchases with continuation token: null
12-12 01:40:50.116: D/IabHelper(23502): Starting async operation: launchPurchaseFlow
Run Code Online (Sandbox Code Playgroud)
这是最后两个被调用的方法,之后当我完成购买时,它不会调用purchasefinishedlistener
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: "
+ purchase);
if (result.isFailure()) {
complain("Error purchasing: " + result);
// setWaitScreen(false);
return;
}
if (purchase.getSku().equals(mySku)) {
Log.d(TAG, "mySku is being consumed.");
mHelper.consumeAsync(purchase, mConsumeFinishedListener);
}
Log.d(TAG, "Purchase successful.");
new AsyncQuestionsActivity().doInBackground();
}
};
Run Code Online (Sandbox Code Playgroud)
从日志到最终都没有任何作用.有什么东西我只是在某种程度上失踪了吗?
And*_*uin 50
我发现了如何解决它.在onActivityResult中实现handleActivityResult.需要在侦听器和已启动的购买流之间建立桥梁.
以下是我使用的代码:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + ","
+ data);
// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
} else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
Run Code Online (Sandbox Code Playgroud)
AndroidPenguin,我遇到了和你一样的问题,但我正确设置了activityresult,但我的purchasefinishedlistener却没有执行.
这是我的onActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (SettingsManager.getBooleanSetting(rootId, "inapppurchase", false)){
Log.d(TAG, "take care of activity result with billing helper");
if (!mBillingService.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);
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
else
super.onActivityResult(requestCode, resultCode, data);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11352 次 |
| 最近记录: |