It appears that using the NetworkType.CONNECTED constraint when scheduling periodic tasks in the WorkManager is not working reliably for me.
One way to reproduce...
The Android device on which the app is installed is connected to a WiFi access point. Block the traffic to the device with a MAC filter that drops the packets. As expected, the network calls on the device start to fail and WM handles it. Next, disable the MAC filter blocking the traffic restoring access to/from the device. One expects the tasks to resume but they never do. Other network calls work without problems, yet WM tasks with the network constraint never run until the app is restarted (killed/run again)
Temp. resolution: dropping the constraint of NetworkType.CONNECTED when scheduling tasks in WorkManager resolves the problem but then of course you will make the requests even if the network is down, waking the device up and unnecessarily using up the battery.
- Compile SDK version 28
- Android 5.1.1
If anyone has a better work around please share.
Update: Another key thing is to ensure that any period job always returns ListenableWorker.Result#success()