Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android JobScheduler always works for 1 minute

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?

like image 235
onCreate Avatar asked Dec 31 '14 09:12

onCreate


1 Answers

From API 26 (Oreo), setting a smaller period than 15 minutes for periodic jobs will execute at least after 15 minutes.

like image 178
Imran Haidry Avatar answered Sep 24 '22 07:09

Imran Haidry