Schedule tasks with WorkManager

Schedule that 3am, WiFi-only photo backup with WorkManager.

Your boss walks in the door. "Our podcasting app just reached 1 million users!" he says. This is good news, considering that fact that you've been working on it for the past eleven months. "But it needs some improvements," he says.

A podcasting app is just one of many use cases for WorkManager. Also applicable are photo backup services, error logging dumps, and other tasks where a large amount of data needs to be sent to a server.

Currently, each podcast episode gets downloaded as soon as it's available. This is not ideal, because the user could be on a cellular data plan, and it can cost them money. To fix this, you want to download new episodes during the night -- when the app is on WiFi and when the device is idle (not being used).

You decide to download new episodes between 1am-3am every day. After a quick web search, you decide on the Android WorkManager library to fetch new episodes.

Let's get started!