尽管文档setOverrideDeadline
https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#setOverrideDeadline(long)
此参数用作计时器任务。我的意思是它每毫秒延迟唤醒设备。
int type = entity.getJobId();
long now = System.currentTimeMillis();
PersistableBundle extras = new PersistableBundle();
extras.putInt(A_.JOBSCHEDULER_TYPE, type);
JobInfo jobInfo = new JobInfo.Builder(type, new ComponentName(ctx, entity.getJobClass()))
.setMinimumLatency(nextTime - now)
.setOverrideDeadline(TimeUnit.SECONDS.toMillis(60))
.setExtras(extras)
.build();
JobScheduler jobScheduler =
(JobScheduler) ctx.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.schedule(jobInfo);
如果我使用此setOverrideDeadline(TimeUnit.SECONDS.toMillis(60))
参数,JobService会反复唤醒。为什么呢?
在Android 8.0和Android 8.1上
修改
jobFinished(jobParams, false)
和jobFinished(jobParams, true)