0

I start new JobService as:

 JobScheduler jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
    if (jobScheduler != null) {
        jobScheduler.schedule(
                new JobInfo.Builder(JOB_ID_LOAD_IMAGE,
                        new ComponentName(getApplicationContext(), ImageLoadJobService.class))
                        .setOverrideDeadline(0L)
                        .setPeriodic(900000)
                        .setPersisted(true)
                        .build()
        );
    }

And than user can change period of updating data. How can I change period of my JobService? Should I stop it and than repeat again?

Thanks everyone for answers in advance!

Ening
  • 455
  • 3
  • 19

1 Answers1

0

You should call jobScheduler.cancel(JOB_ID_LOAD_IMAGE); and then reissue your job with the updated period as a new job via your code above.

Unfortunately, the API does not offer an update to the JobInfo object so cancelling then re-creating is the only way to issue a new period for your job.

Good Luck and Happy Coding!

kandroidj
  • 13,784
  • 5
  • 64
  • 76