in my SDK I use JobIntentService
to do some work in background. I noticed that the job doesn't start immediately when I call enquequeWork()
, but it starts some time later. I can't use foreground service
to do the work, because the app can't run as foreground by client's request.
Is there any other way I can force the job to be done immediately after enqueueWork()
is called?
I also use WorkManager
's PeriodicWorkRequest
to check if the work can be done, every X minutes and if so, I call for the JobIntentService
and enqueue the work I need.
Is there any other way I can force the job to be done immediately after enqueueWork() is called?
No. JobIntentService
uses JobScheduler
, and JobScheduler
runs jobs when it decides to.
I also use WorkManager's PeriodicWorkRequest to check if the work can be done, every X minutes and if so, I call for the JobIntentService and enqueue the work I need.
You might consider simplifying your code and just do your work in your Worker
, if the only supplier of work to the JobIntentService
is this Worker
. Or, have the actual "work" be performed by a class that can be used by either your Worker
or your JobIntentService
. Just as JobIntentService
uses JobScheduler
, so does WorkManager
. Your current system appears to have a job just trigger another job, and you could reduce latency by consolidating those.