我做了什么:
如何调试我的应用以便我可以逐步完成IAP流程并观察问题? 是否可以附加调试器并逐步完成IAP过程?
更新
所以这里的进展非常缓慢,因为谷歌需要2个小时上传一个alpha版本 - RIDICULOUS!
通过为我的应用程序提供大量的Toast消息(并在我运行我的应用程序时录制视频以检查所有消息),我发现IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
在被引用时不会被调用在launchPurchaseWorkflow()
中,请参阅以下内容:
protected void launchPurchaseWorkflow(Activity activity, String sku)
{
mHelper.launchPurchaseFlow(
activity,
sku,
Constants.PURCHASE_REQUEST_ID,
mPurchaseFinishedListener,
Constants.DEVELOPER_PAYLOAD);
}
因此,成功购买不会触发对应用的回调。因此,应用程序无法更新UI ...重新启动应用程序后,它会成功完成清单,然后检测到购买。
我做错了什么? (文件告诉我的是什么?)
答案 0 :(得分:1)
解决方案:
1)复制" util"从var app = express();
到您的项目的文件夹(首先确保您的SDK Manager已更新到最新的" Google Play结算库")
2)从\sdk\extras\google\play_billing\samples\TrivialDrive\src\com\example\android\trivialdrivesample
复制所有重要的回调,例如\sdk\extras\google\play_billing\samples\TrivialDrive\src\com\example\android\trivialdrivesample\MainActivity.java
,IabHelper.QueryInventoryFinishedListener mGotInventoryListener
,IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
3)我写了这个实用工具方法,您也可以将其复制到您的代码中:
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener
到目前为止一切都很好......还有一件事你需要让它全部工作!
4)您会认为,既然您已将参考// (arbitrary) request code for the purchase flow
public static int PURCHASE_REQUEST_ID = 1234;
protected void launchPurchaseWorkflow(Activity activity, String sku)
{
mHelper.launchPurchaseFlow(
activity,
sku,
Constants.PURCHASE_REQUEST_ID++,// just needs to be a positive number and unique
mPurchaseFinishedListener,
Constants.DEVELOPER_PAYLOAD);
}
传递给mPurchaseFinishedListener
,那么您将会感到高兴 - 但是您已经#39 ;不是!
将此代码复制到您在mHelper.launchPurchaseFlow()
mHelper.launchPurchaseFlow()
现在可以工作!!
我花了5天时间解决这个"问题" - 你会认为在trivialdrivesample中更好地记录需要@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
if (ApplicationContext.mHelper == null) return;
// Pass on the activity result to the helper for handling
if (!ApplicationContext.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.");
}
}
。事实上,绝对没有方法评论它!