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);