Reputation: 77
Is there any easy way how to change repeat interval of PeriodicWorkRequest
?
Let's have a Worker
which is triggered every 6 hours and already enqueued, but i need to change it to 3 hours period.
If the solution is cancel the request and create new one, what is the clean way without duplicate it?
Upvotes: 4
Views: 1294
Reputation: 482
make period work unique, by using WorkManager.enqueueUniquePeriodicWork
.
and use ExistingPeriodicWorkPolicy.REPLACE
as policy.
refer: https://developer.android.com/reference/androidx/work/WorkManager#enqueueuniqueperiodicwork
note that workmanager version should be above or equal to 1.0.0-alpha03
Upvotes: 6