Store billing client inside Application scope
Hi, I would much appreciate if someone help me with this quiestion. I have multiple-activities app, and I'm setting app billing client in each activity which I don't like. And because of this I had some issues when calling endConnection() in onDestroy(), so I just don't call endConnection any longer. Is this possible to keep single instance of bllling client inside Application scope, so that I can reuse it in any activity? What are the pros/cons. I want to move to single activity approach in future and use billing client in single activity, but currently I don't have enough time to rewrite the whole navigation.
It would be nice if billing client is mostly handled on google lib side, I mean you can move the logic of starting and ending billing connection to your side, so developers wouldn't worry about it. You can do the same way as Timber, It can be planted on the start of Application.
I had good success putting all the billing stuff in its own viewModel when I did it.
Then simply associate the VM with any activity where you want to use it.
I would startConnection in the VM init and endConnection in VM onCleared.
@matale thanks. did you have any memory leaks?
@matale thanks. did you have any memory leaks?
I don't think so but also didn't look for them specifically.