I'm trying to implement background refreshing service with new JobScheduler(compat by tatarka). Here is my Service
@Override
public boolean onStartJob(JobParameters params) {
Timber.i("on start job: " + params.getJobId());
return true;
}
@Override
public boolean onStopJob(JobParameters params) {
Timber.i("on stop job: " + params.getJobId());
return true;
}
Here is my JobInfo
public void scheduleJob(View v) {
JobInfo job = new JobInfo.Builder(kJobId++ /*jobid*/, new ComponentName(getActivity(), RefreshJobService.class))
.setPeriodic(2000)
.build();
mTestService.scheduleJob(job);
}
In log i see that my job always works for 1 minute
12-31 12:38:03.884 10059-10059/@/RefreshJobService﹕ on stop job: 0
12-31 12:39:03.891 10059-10059/@/RefreshJobService﹕ on start job: 0
12-31 12:40:03.911 10059-10059/@/RefreshJobService﹕ on stop job: 0
12-31 12:42:08.841 10059-10059/@/RefreshJobService﹕ on start job: 0
12-31 12:43:08.858 10059-10059/@/RefreshJobService﹕ on stop job: 0
So why? I'm set periodic to 2000ms, any value do not influence to 1 minute interval for job. Why?
From API 26 (Oreo), setting a smaller period than 15 minutes for periodic jobs will execute at least after 15 minutes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With