购买完成后我没有收到 onIabPurchaseFinished
I don't recieve onIabPurchaseFinished when purchase is finished
mHelper.launchPurchaseFlow(End.this, "resurrect", 10001,
new IabHelper.OnIabPurchaseFinishedListener() {@Override
public void onIabPurchaseFinished(IabResult result, Purchase info) {
Log.v("end:iabfinished:result", result.toString());
Log.v("end:iabfinished:info", info.toString());
if (result.isSuccess()) {
//here's some code which was never executed
} else if (result.getResponse() != IabHelper.BILLING_RESPONSE_RESULT_USER_CANCELED) Toast.makeText(End.this, result.getMessage() + " (ERROR CODE " + result.getResponse() + ")", Toast.LENGTH_LONG).show();
try {
mHelper.consumeAsync(info, new IabHelper.OnConsumeFinishedListener() {
@Override
public void onConsumeFinished(Purchase purchase, IabResult result) {
Log.v("end:ouconsumeF:purchase", purchase.toString());
Log.v("end:ouconsumeF:result", result.toString());
}
});
} catch (Throwable e) {
Log.v("end:throwableonconsume", e.toString()); //debug
} //really dont know how it works
}
}, payload);
此代码成功打开 google 我购买的游戏片段。但是当购买成功完成时,不会调用 onIabPurchaseFinished。调用它的唯一情况是出现错误 7 "Item Already Owned"
我使用从示例项目复制的代码 "TrivialDrive" (com.example.android.trivialdrivesample.util)
我刚刚忘记写 onActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
if (mHelper == null) return;
// Pass on the activity result to the 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);
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
mHelper.launchPurchaseFlow(End.this, "resurrect", 10001,
new IabHelper.OnIabPurchaseFinishedListener() {@Override
public void onIabPurchaseFinished(IabResult result, Purchase info) {
Log.v("end:iabfinished:result", result.toString());
Log.v("end:iabfinished:info", info.toString());
if (result.isSuccess()) {
//here's some code which was never executed
} else if (result.getResponse() != IabHelper.BILLING_RESPONSE_RESULT_USER_CANCELED) Toast.makeText(End.this, result.getMessage() + " (ERROR CODE " + result.getResponse() + ")", Toast.LENGTH_LONG).show();
try {
mHelper.consumeAsync(info, new IabHelper.OnConsumeFinishedListener() {
@Override
public void onConsumeFinished(Purchase purchase, IabResult result) {
Log.v("end:ouconsumeF:purchase", purchase.toString());
Log.v("end:ouconsumeF:result", result.toString());
}
});
} catch (Throwable e) {
Log.v("end:throwableonconsume", e.toString()); //debug
} //really dont know how it works
}
}, payload);
此代码成功打开 google 我购买的游戏片段。但是当购买成功完成时,不会调用 onIabPurchaseFinished。调用它的唯一情况是出现错误 7 "Item Already Owned"
我使用从示例项目复制的代码 "TrivialDrive" (com.example.android.trivialdrivesample.util)
我刚刚忘记写 onActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
if (mHelper == null) return;
// Pass on the activity result to the 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);
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}