Hey guys, I’m trying to write a simple coroutine t...
# coroutines
s
Hey guys, I’m trying to write a simple coroutine to await a callback and return a value, but for some reason my code hangs and the response never comes. Here’s the gist: https://gist.github.com/Schadenfeude/8d0ccb88eb1b874d4e3cbf43327fe266 The last log I see is the one on line 19
Log.d("BillingManagerProvider", "suspendCoroutine: startConnection")
g
Maybe you never get result of callback from BillingClient
because if you see this log it means that now non-coroutine code works and coroutine waiting for result of callback
Actually your code looks fine you should get some result from BillingManager
s
Yeh, but it never comes, that’s why I’m baffled as to what I’m doing wrong
g
I would check logs and billingmanager
I have very similar code for GoolgePlay
Maybe you just never get onBillingSetupFinished for some reason
One more note about your solution. BillingClient has a method to cancel connection, so to avoid leaks use suspendCancellableCoroutine builder and function
cont.,invokeOnCancellation
to cancel connection