I’m facing an issue with WorkManager in my Android project where I enqueue a worker, but the worker’s code does not run as expected.
The first time worker is enqueued everything works fine. But problem occurs when enqueuing worker after first time.
Here’s what happens:
- Most of the time, when I enqueue the worker, the status shows as Running, but the worker’s doWork() method is not executed.
- Sometimes, the worker’s status does not even change to Running or Enqueued, despite enqueuing it.
- The worker only starts running after I “Force Stop” the app and then restart it.
I’ve checked the following:
- The worker is not constrained (i.e., no constraints like battery, network, etc.).
- I’m using WorkManager version 2.3.4
Why is the worker not running immediately, and why does it only start after I force stop the app and restart it? What could be causing this, and how can I ensure the worker runs as expected?
Any insights would be appreciated!