I used to start LocationService
with following command
startService(new Intent(MainActivity.this, LocationUpdateService.class));
but since Oreo
does not support it, I moved to JobSchedular
and now i do this.
final int hourly = (int)TimeUnit.HOURS.toSeconds(1);
final int toleranceInterval = (int) TimeUnit.MINUTES.toSeconds(15);
Job job = dispatcher.newJobBuilder()
.setLifetime(Lifetime.FOREVER)
.setService(LocationUpdateService.class)
.setTag("LocationJob")
.setRecurring(true)
.setReplaceCurrent(true)
.setTrigger(Trigger.executionWindow(hourly,toleranceInterval))
.build();
return job;
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job job=createJob(dispatcher);
dispatcher.schedule(job);
Initially my location service was used to send me user's lat/lng
after every 1 hour. Now with FirebaseJobDispatcher
i scheduled this job, and it runs Location service
after every 1 hour. So what's the difference is there actually?
In both cases my location service is doing network operation and sending user's lat/lng
after every 60 minutes. I want to know what performance gain we get when using JobSchedular