저는 firebase 작업 디스패처를 사용하고 있으며 인터넷 연결이있을 때마다 매분마다 실행해야하는 간단한 주기적 작업을 프로그래밍하고 있습니다. 배터리 수명을 향상시키고 다른 응용 프로그램도 작동시킬 수 있지만 지연 시간이 너무 길기 때문에 작업이 정시에 실행되지 않는다는 것을 알고 있습니다. 그것은 원하는 1 분에 비해 너무 길어서 25 분에 도달 할 수 있습니다. 정기 작업을 적어도 매 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);