Start job in specific time and run periodically every to 2 hours to 5 days
See original GitHub issuei want to schedule a complex job that is firing in specific time and recurring every specific time for range of another time. example : fire alarm sound at 12:00 am and repeating every 2 hours and ending time of job is + 5days
when i setWindowExecution() or setExact() with setPeriodic() it’s throw exception exceptions: Can’t call setExecutionWindow() on a periodic job. Can’t require any condition for an exact job.
Here Is My Code
JobRequest.Builder builder = new JobRequest.Builder(Constants.APP_JOB_TAG) .setExecutionWindow(startTime, endExecutionTime) // .setExact(startTime) .setBackoffCriteria(5_000L, JobRequest.BackoffPolicy.EXPONENTIAL) .setExtras(extras) .setRequirementsEnforced(true) .setUpdateCurrent(true); if (taskModel.getTask_repeat() > 0) { builder.setPeriodic(taskModel.getTask_repeat() + (2 * ONE_MINUTE_IN_MILLIS), taskModel.getTask_repeat()); } int jobId = builder.build().schedule();
do i miss understood something ? please help
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6
Top GitHub Comments
@pedrodimoura thanks for helping out.
feature not supported yet, hope to be supported soon
Hi, @ebnrdwan ! You can’t call setExecutionWindown on a periodic job. If you want to schedule a periodic job, just set a time interval in milliseconds on
setPeriodic
method.For example, I have a job that execute every 15 minutes and 5 minutes flex time interval, check it out:
JobRequest.Builder(JobServiceSync.TAG).setPeriodic(TimeUnit.MINUTES.toMillis(15), TimeUnit.MINUTES.toMillis(5)).build();
And remember, when you use
setPeriodic
to schedule a job, the min. time interval is 15 minutes. This is a AlarmManager limitation.