I had an update with the following code that adds a new periodic worker every three hours.
fun runCouponValidatorWorker() {
val constraints = Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()
val worker = PeriodicWorkRequestBuilder<CouponValidatorWorker>(3, TimeUnit.HOURS).setConstraints(constraints).build()
WorkManager.getInstance()?.enqueueUniquePeriodicWork("couponValidatorWorker", ExistingPeriodicWorkPolicy.REPLACE, worker)
}
I'd like to release an update that will "kill" this worker and every scheduled instance of this worker.
What would be the best way to do that?
Did you try simply calling this:
WorkManager.getInstance(context).cancelUniqueWork("couponValidatorWorker")
WorkManager.getInstance().cancelAllWorkByTag(TAG)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With