我已经尝试了evernote-android-job中的所有以下方法。似乎 schedulePeriodicJob 方法在某个时间间隔内运行,而 scheduleAdvancedJob 方法只运行一次。
通过一些示例帮助我如何设置 setExecutionWindow、setExact 和 setPeriodic 的值?
private void scheduleAdvancedJob() {
PersistableBundleCompat extras = new PersistableBundleCompat();
extras.putString("key", "Hello world");
int jobId = new JobRequest.Builder(DemoSyncJob.TAG)
.setExecutionWindow(30_000L, 40_000L)
.setBackoffCriteria(5_000L, JobRequest.BackoffPolicy.EXPONENTIAL)
.setRequiresCharging(true)
.setRequiresDeviceIdle(false)
.setRequiredNetworkType(JobRequest.NetworkType.CONNECTED)
.setExtras(extras)
.setRequirementsEnforced(true)
.setUpdateCurrent(true)
.build()
.schedule();
}
private void schedulePeriodicJob() {
int jobId = new JobRequest.Builder(DemoSyncJob.TAG)
.setPeriodic(TimeUnit.MINUTES.toMillis(15), TimeUnit.MINUTES.toMillis(5))
.build()
.schedule();
}
private void scheduleExactJob() {
int jobId = new JobRequest.Builder(DemoSyncJob.TAG)
.setExact(20_000L)
.build()
.schedule();
}