Google forces me to stop using the AlarmManager because of Excessive Wakeups. I should now use JobScheduler, but my app should support older devices with API <21. So I have to use the Firebase JobDispatcher :-(
However, in my opinion, the JobDispatcher is unreliable, unlike AlarmManager.
I set the interval to every 60 secs (1 min). But the gaps between JobService.onStartJob() are:
1, 10, 6, 1, 16, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 4, 0, 1, 8 mins.
If I set the interval to 10 mins, the gaps are:
11, 10, 10, 10, 10, 10, 21, 12, 10, 10, 10, 10, 10, 15, 10, 41, 10, 13, 14, 14, 22, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 19, 10, 10, 34, 14, 10, 10, 10, 12, 10 mins.
My smartphone (Samsung Galaxy Alpha, Android 5.0.1) is connected to power and not in standby, power safe option is deactivated.
What am I doing wrong?
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
Job jobWifi = dispatcher.newJobBuilder()
.setService(ConnectionJobService.class)
.setTag("tag")
.setRecurring(true)
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.executionWindow(60, 60)) // 600, 600
.setReplaceCurrent(true)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.setExtras(extras)
.build();