I am scheduling a job with Firebase Job Dispatcher to be executed periodically every 1 minute. Here is my configuration:
Job job = dispatcher.newJobBuilder()
.setLifetime(Lifetime.FOREVER)
.setService(JobService.class)
.setTag("JobDispatcher")
.setReplaceCurrent(false)
.setRecurring(true)
.setTrigger(Trigger.executionWindow(30, 60))
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
.build();
I have kept a logger on the onStartJob of the job service to check when the jobs are executed. Although I have kept 30-60 second window as job interval time, the job is executed every 20-25 mins after a while. The logger looks like this:
Job start 2018-02-14 9:28:16
Job start 2018-02-14 9:30:25
Job start 2018-02-14 9:31:11
Job start 2018-02-14 9:32:46
Job start 2018-02-14 9:34:22
Job start 2018-02-14 9:37:16
Job start 2018-02-14 9:42:27
Job start 2018-02-14 9:48:36
Job start 2018-02-14 9:57:33
Job start 2018-02-14 10:09:11
Job start 2018-02-14 10:24:29
Job start 2018-02-14 10:41:16
Job start 2018-02-14 11:01:52
Job start 2018-02-14 11:25:16
Job start 2018-02-14 11:52:27
Job start 2018-02-14 12:15:06
For first few minutes, the service runs every 1-2 mins which is fine. After some time, interval increases in a linear manner.
NB: I am testing on Android 5.1.1 and in Huwaei Device, the app is enlisted as protected app.
This is due to your
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
If you have a look at this file https://github.com/firebase/firebase-jobdispatcher-android/blob/master/jobdispatcher/src/main/java/com/firebase/jobdispatcher/RetryStrategy.java its is evident that the retry statergy increases linearly in
/** Expected schedule is: [30s, 60s, 90s, 120s, ..., 3600s] */
You can try creating your own custom retry policy by following the link below
https://github.com/firebase/firebase-jobdispatcher-android/issues/179