I had this problem sometimes, and in my case I tracked it to the point that if the onServiceConnected method in IabHelper can be called more than once if the underlying service is disconnected and reconnected (for example, due to an intermittent network connection).
The specific operations in my case were: "Cannot start the asynchronous operation (update inventory) because another async (launchPurchaseFlow) operation is being performed."
As my application is written, I cannot call launchpurchaseFlow until I have completed queryInventory, and I only call queryInventory from my onIabSetupFinished function of the handler.
The IabHelper code will call this handler function whenever its onServiceConnected is called, which can happen more than once.
Android documentation for onServiceDisconnected says:
Called when the connection to the Service is lost. This usually happens when the service hosting process crashed or was killed. This does not eliminate the ServiceConnection - this service binding will remain active and you will receive a call to onServiceConnected (ComponentName, IBinder) when the next service is running.
which explains the problem.
Perhaps IabHelper should not call the listener's onIabSetupFinished function more than once, but, on the other hand, it was trivial to fix the problem in my application by simply not calling queryInventory from this function, if I already did this and got the results.
sheltond Jun 19 '14 at 11:18 2014-06-19 11:18
source share