Issue
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?
Solution
Did you try simply calling this:
WorkManager.getInstance(context).cancelUniqueWork("couponValidatorWorker")
Answered By - Arseny Levin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.