当您阅读Trigger.executionWindow
的文档时,它会说
@param windowStart The earliest time (in seconds) the job should be considered eligible to run.
* Calculated from when the job was scheduled (for new jobs) or last run (for recurring jobs).
* @param windowEnd The latest time (in seconds) the job should be run in an ideal world.
* Calculated in the same way as {@code windowStart}.
第二个数字也是窗口号或重复间隔
以及FirebaseDispatcher的GitHub存储库中的这些行
// start between 0 and 60 seconds from now
.setTrigger(Trigger.executionWindow(0, 60))
这是我的代码
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job myJob = dispatcher.newJobBuilder()
.setService(MyJobService.class)
.setConstraints(Constraint.DEVICE_CHARGING,
Constraint.ON_UNMETERED_NETWORK,
Constraint.DEVICE_IDLE)
.setTag("DAILY-MAIN-SYNC")
.setRecurring(true) // setRecurring
// don't persist past a device reboot
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.executionWindow(1, (int) TimeUnit.DAYS.toSeconds(1) ))
.setExtras(myExtrasBundle)
.build();
dispatcher.schedule(myJob);
那么此代码将每天执行一次,还是我缺少某些东西?