AAA*_*ton 110 android in-app-billing
我一直在尝试为我的第一个应用程序设置应用内结算,并且一直在使用android.test.purchased sku.购买过来了,我设法将SKU放入我的库存中,但正如标题所示,onIabPurchaseFinished永远不会被调用.
我认为它可能与此日志有关:"无法保存哪个视图具有焦点,因为焦点视图com.android.internal.policy.impl.PhoneWindow$DecorView@406743d0没有id".在进入Google Play之前就会弹出.我不太确定这意味着什么......
发布购买:
mHelper.launchPurchaseFlow(this, sku, 10001, mPurchaseFinishedListener, "");
Run Code Online (Sandbox Code Playgroud)
和听众:
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase info) {
System.out.println("Purchase Finish heard something");
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
return;
} else{
Log.d(TAG,"Success!");
}
}
};
Run Code Online (Sandbox Code Playgroud)
bug*_*gzy 204
尝试将此添加到调用的Activity mHelper.launchPurchaseFlow(..)
:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
// 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.");
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
我刚发现另一个重要的事情:用于启动购买流程的requestCode必须> = 0!
我使用"new Random().nextInt()"来生成一个随机的requestCode,有时它可以工作,有时却没有.现在我在以下文档中发现,requestCode不应该是负数:
归档时间: |
|
查看次数: |
12973 次 |
最近记录: |