I am using
I would like to know if it’s ever possible for the
onDestroy() to be called even without
onHandleWork() called in a JobIntentService.
Basically, what’s the lifecycle of a JobIntentService. Is
onHandleWork() guaranteed to be called at least once before
onDestroy() gets invoked?
The behaviour of
JobIntentService is different depending on the version of Android running on the target device (prior to API level 26, or API level 26 or higher).
However, generally you can assume that
onHandleWork() is called at least once before
onDestroy(). There would be no reason to start the
Service if there was no work for it. Generally the
Service would only be started when there is work in the queue, in which case
onHandleWork() would be called immediately after the
Service is started.