Baptiste
Baptiste

Reputation: 1

Any way to kill ALL old work planned by WorkManager?

I had to use WorkManager on a mobile app, so it can gather current user emergencies using a PeriodicWorkRequest. But because of my lack of documentation, I implemented it in a bad way, and I ended up having the same work running dozens of times.

When I spotted it, I changed my way to initalize the work. It now has a tag and is launched using EnqueueUniqueWork() to be sure it is run only once. Also, I added a piece of code that is supposed to check all works running in the app, and kill them all if you have more than 1, using cancelAllWork() and pruneWork().

Despite working on my dev environment, some devices seem to have difficulties getting rid of these and still receive the notifications dozens of times.

How do I completely clean my WorkManager, knowing uninstallation could be a solution, but that I will not do it unless I am sure at 100% it will work ?

Upvotes: 0

Views: 22

Answers (0)

Related Questions