Afzal Najam
Nov 27, 2020

I think this works for majority of the cases but if you call ForegroundServiceLauncher.startService() multiple times without calling ForegroundServiceLauncher.stopService(), then later try to stop the service by calling ForegroundServiceLauncher.stopService(). context.stopService() will not get called because isStarting will be true.

I think another flag for created is required, especially if the ForegroundServiceLauncher instance has to be a Kotlin object, and that `isCreated` flag can be set to false when the service goes through `onDestroy()`

We came up with this fork that handles it better (I think):
https://gist.github.com/AfzalivE/08708f9e08760cc60b9f5609320e764c

Would love to hear your thoughts.

Afzal Najam
Afzal Najam

Written by Afzal Najam

Senior Android Developer @ Doist

No responses yet