In case of Service
and IntentService
the main differences are Service
runs on the main thread while IntentService
is not, and
JobIntentService
is essentially a replacement for IntentService
, offering similar semantics in a way that "plays nice" with Android O's new background execution restrictions. It is implemented as a scheduled job on O+, but that's abstracted away -- your app doesn't need to care that it's a job.
Never schedule()
a job directly that you expect to use via the JobIntentService
support class. JobIntentService
uses the enqueue()
system in the job scheduler, and you cannot mix and match enqueue()
and schedule()
for the same job.
JobService is used to schedule background work with JobScheduler. The above code snippet for ExampleJobService.class
can be used to start a JobService.
Where as, a JobIntentService can be started using below code:
// JobIntentService for background task
Intent i = new Intent(context, ExampleJobIntentService.class);
ExampleJobIntentService.enqueueWork(context,i);
The JobIntentService is capable to work for both before and after Android Oreo devices.
When running on older than Oreo versions of the platform, JobIntentService will use Context.startService. When running on Android O or later, the work will be dispatched as a job via JobScheduler.enqueue.
Actually, JobIntentService would be better if rename to JobedIntendService, one get obscured with JobService at first glance.