我正在学习Google中关于如何实现应用内计费的教程和代码示例。问题是我在一个碎片里做这个。
直到最后一步,一切似乎都实现得很好,但是我应该实现这个方法:
@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.");
}
}
问题当然是这个受保护的方法在片段中不存在。只有一个公共方法,在完成应用内购买时不会调用它。
最佳答案
这些链接可能有帮助
http://code.google.com/p/marketbilling/issues/detail?id=131
Calling startIntentSenderForResult from Fragment (Android Billing v3)
关于java - fragment 中没有onActivityResult()。对于应用内结算,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26640057/