Reputation: 843
I want to have a JobScheduler schedule a job to run after 5 minutes, and then it will continue to run every 3 minutes. How can i schedule a job with an initial delay?
My current code:
JobInfo.Builder builder = new JobInfo.Builder(32, componentName);
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
builder.setPeriodic(SUBSEQUENT_EXECUTION_INTERVAL);
} else {
builder.setMinimumLatency(SUBSEQUENT_EXECUTION_INTERVAL);
}
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.schedule(builder.build());
Upvotes: 2
Views: 722
Reputation: 843
Well the ideal situation at this time is to use Android Arch's WorkManager. With this you can set an overrideDeadline that runs your task after an initial delay. More info can be found here
Upvotes: 0