Search code examples
androidkotlingoogle-cloud-firestoregoogle-tasks-api

How to prevent memory leaks from gms.Task?


I use tasks in viewModel and want to remove listeners in onCleared but there is no method to do that, is it needed or not? I have found onCompleteListener with activity paramenter that in result clears listener in onStop but i'd like to leave authentication logic in VM.


Solution

  • It is not needed. It should be garbage collected after the Task itself completes and becomes garbage collected.