简体   繁体   English

如何在每天的特定时间运行 Job?

[英]How to run a Job at a specific time every day?

I am new on using job libraries as Job Scheduler.我是使用作业库作为作业调度程序的新手。 I have seen a lot of documentation and none of them responds to my question, is it possible to schedule a job for 9PM (for example) and that same job runs everyday at 9PM(the hour of the initial job).我看过很多文档,但没有人回答我的问题,是否可以将工作安排在晚上 9 点(例如),并且同一工作每天晚上 9 点(初始工作的时间)运行。 What I have seen are people setting a periodic time but I dont know if the periodic starts when the job runs for the first time our if I could specify an hour.我所看到的是人们设置了一个周期性的时间,但我不知道如果我可以指定一个小时,那么在第一次运行作业时周期性是否开始。

Do you mean that you want to set exact, periodic job?您的意思是要设置精确的定期工作吗? If yes, it is not possible.如果是,那是不可能的。 Every periodic job is inexact.每个定期工作都是不准确的。 This mean that job will be executed at any time in a window of flex length at the end of the period.这意味着作业将在周期结束时的弹性长度窗口中随时执行。 And the requirement is that the flex time is at least 5% of the period.并且要求弹性时间至少为周期的 5%。

Take a look at: https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#setPeriodic(long,%20long)看看: https : //developer.android.com/reference/android/app/job/JobInfo.Builder.html#setPeriodic(long,%20long)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM