How to reschedule JobScheduler that I started with setPeriodic()
, I want to change the scheduler time later with user input.
JobInfo.Builder builder =
new JobInfo.Builder(JOB_ID, new ComponentName(this, MyJobScheduler.class));
builder
.setPeriodic(15000)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setPersisted(true);
jobScheduler.schedule(builder.build());
Currently, there is no option to reschedule a job. What you can do is call the cancel() method to cancel the job with the given job id and schedule a new job. So it would look something like:
jobScheduler.cancel(JOB_ID);
// Construct a new JobInfo.Builder
jobScheduler.schedule(builder.build());