0
我正在使用Firebase作业调度程序,并且正在编程一个简单的周期性作业,应该在互联网连接时每分钟左右运行一次。 我知道作业不会准时运行,因为他们想要延长电池寿命,并允许其他应用程序也能正常工作,但延迟时间太长。它可以达到25分钟,这比想要的1分钟长得太长。 有没有办法使周期性作业至少每3-5分钟运行一次?有没有办法让周期性任务有更短的延迟?
THIX是我如何编程周期任务:如果你想
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(MainActivity.this));
Job myJob = dispatcher.newJobBuilder()
// the JobService that will be called
.setService(MyJobService.class)
// uniquely identifies the job
.setTag("my-unique-tag")
.setRecurring(true)
.setLifetime(Lifetime.FOREVER)
// start between 0 and 10 seconds from now
.setTrigger(Trigger.executionWindow(0, 10))
.setReplaceCurrent(true)
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
// constraints that need to be satisfied for the job to run
.setConstraints(
// only run on an unmetered network
Constraint.ON_UNMETERED_NETWORK
)
.build();
dispatcher.mustSchedule(myJob);