Let's say I have a periodic job and will run every 15mins. But I want the first time run is 15 mins later not immediately. I have read the doc and source code and cannot find a public api to do it..
Any help?
Periodic jobs should work this way. Usually it waits one period until the job runs for the first time.
@vRallev I schedule job when application oncreate. After test, when my app start, the onRunJob callback will be called immediately...
here is my job code.
private void scheduleNetworkJob() {
int jobId = new JobRequest.Builder(NetworkChangeJob.TAG)
.setPeriodic(JobRequest.MIN_INTERVAL)
.setRequiredNetworkType(JobRequest.NetworkType.CONNECTED)
.setPersisted(true)
.setUpdateCurrent(true)
.build()
.schedule();
}
Sorry, but I don't have a better solution than to manually skip the first period. You can either use the shared preferences or you can also check when the job was scheduled.
You can create two jobs where the first is executed once after an offset and it will execute the 2nd which will be periodic.
@vRallev
It would be very good to make possible to use .setExact(...) and .setPeriodic(...) both in one job...
You can do this on your own, but I wouldn't recommend it. That's against the whole purpose of this library to make background jobs as battery friendly as possible.
Closing because of inactivity.