Android in-app-billing. When to unregister the ResponseHandler?

故事扮演 提交于 2019-12-11 03:07:17

问题


We implemented In-app Billing one year ago with no problems following the sample code from the documentation. Some weeks ago we noticed users complaints about not getting their items. While debugging the code we found that the following sentence was the root of the problem:

/**
 * Called when this activity is no longer visible.
 */
@Override
protected void onStop() {
    super.onStop();
    ResponseHandler.unregister(mDungeonsPurchaseObserver);
}

On my Samsung Galaxy S device this method is being called when the Market screen appears, clearing the observer and interrupting the overall circuit. We've moved the call to the OnDestroy method instead and it's working ok now.

Is this the correct way to handle the problem? Has anyone experienced this?


回答1:


I was facing the same problem. I've implemented a queue on ResponseHandler: if the observer is null, I put the information on the queue; as soon an observer is added, I call it using the information from the queue. It makes sense in my application and it seems to be working fine.

I do not know if putting in onDestroy is a good idea, because it makes no sense to update the interface of an Activity that is not visible.

Are you experiencing any problem with your solution?



来源:https://stackoverflow.com/questions/9590019/android-in-app-billing-when-to-unregister-the-responsehandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!