Set initial delay for periodic workers

pull/156/head
M66B 6 years ago
parent fc2c972062
commit 0042a1e580

@ -163,6 +163,7 @@ public class WorkerCleanup extends Worker {
PeriodicWorkRequest workRequest =
new PeriodicWorkRequest.Builder(WorkerCleanup.class, CLEANUP_INTERVAL, TimeUnit.HOURS)
.setInitialDelay(CLEANUP_INTERVAL, TimeUnit.HOURS)
.setConstraints(constraints.build())
.build();
WorkManager.getInstance(context)

@ -54,6 +54,7 @@ public class WorkerPoll extends Worker {
Log.i("Queuing " + getName() + " every " + pollInterval + " minutes");
PeriodicWorkRequest workRequest =
new PeriodicWorkRequest.Builder(WorkerPoll.class, pollInterval, TimeUnit.MINUTES)
.setInitialDelay(pollInterval, TimeUnit.MINUTES)
.build();
WorkManager.getInstance(context)
.enqueueUniquePeriodicWork(getName(), ExistingPeriodicWorkPolicy.REPLACE, workRequest);

@ -56,6 +56,7 @@ public class WorkerWatchdog extends Worker {
PeriodicWorkRequest workRequest =
new PeriodicWorkRequest.Builder(WorkerWatchdog.class, WATCHDOG_INTERVAL, TimeUnit.MINUTES)
.setInitialDelay(WATCHDOG_INTERVAL, TimeUnit.MINUTES)
.build();
WorkManager.getInstance(context)
.enqueueUniquePeriodicWork(getName(), ExistingPeriodicWorkPolicy.KEEP, workRequest);

Loading…
Cancel
Save