[英]Android JobScheduler: If you schedule the same job with periodic time, does it start the period again?
What happens if I schedule the same periodic job (same job ID) and the Job has already been scheduled? 如果我安排相同的定期工作(相同的工作ID)并且工作已经安排,会发生什么? Does it start its period again from the beginning? 它从一开始就再次开始吗?
For example, I call this method twice: 例如,我将此方法调用两次:
JobInfo myLongJob = new JobInfo.Builder(
JOB_ID,
new ComponentName(context, JobSchedulerLongService.class.getName())
).setPeriodic(10000)
.build();
jobScheduler.schedule(myLongJob);
Does scheduling the job second time cause the periodic timer to start counting again? 第二次调度作业会导致周期性计时器再次开始计数吗?
I found it after doing some tests: 我做了一些测试后发现它:
Does scheduling the job the second time cause the periodic timer to start counting again? 第二次调度作业会导致周期性定时器再次开始计数吗?
Yes! 是! and... 和...
It will depend on: 这将取决于:
Added really useful comment from @Gauthier: 从@Gauthier添加了非常有用的评论:
jobId - int: Application-provided id for this job. jobId - int:此作业的应用程序提供的ID。 Subsequent calls to cancel, or jobs created with the same jobId, will update the pre-existing job with the same id. 后续调用取消或使用相同jobId创建的作业将更新具有相同ID的预先存在的作业。 [link to this doc]( http://developer.android.com/reference/android/app/job/JobInfo.Builder.html#JobInfo.Builder(int , android.content.ComponentName)) [链接到此doc]( http://developer.android.com/reference/android/app/job/JobInfo.Builder.html#JobInfo.Builder ( int ,android.content.ComponentName))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.