I am using kotlin coroutines in my JobIntentService
, So on onHandleWork
I would launch my coroutine, once this tasks end, I need to clean up the resources by cancelling the Job
. onDestroy
called immediately after starting of the service, Since I am launching the coroutine on the onHandleWork
it doesn't block the current thread.
Is it mandatory to cancel the coroutine after finishing the task ?
If so, When to release the coroutine resources in the android
Service
lifecycle
Can anyone help me with this?