In the case Service, the IntentServicemain differences Serviceare made in the main thread, but IntentServicenot, and the last one ends when the work is done, when we have to call either stopService()or stopSelf()to stop Service.
Both of them can simply be transferred to startService().
How about JobServiceu JobIntentService?
Take the following code snippet:
JobInfo job = new JobInfo.Builder(id, new ComponentName(context, ExampleJobService.class))
.build();
JobScheduler scheduler = (JobScheduler) context
.getSystemService(Context.JOB_SCHEDULER_SERVICE);
scheduler.schedule(job);
Can ExampleJobService.classrefer both to JobServiceand to JobIntentService?
Will the behavior be the same as with Serviceand IntentService(except the JobSchedulertask may not start right away)?
source
share