Working with WorkManager

We have seen how to do work on the main application thread, and we have seen how to use background threads for things like disk and network I/O.

Sometimes, though, we may need to do work that happens completely independently of the UI

Your primary option for those scenarios is WorkManager.

The Role of WorkManager

This is not to say that WorkManager is the only solution for background work. WorkManager is designed for “deferrable” work — work that you need to have done but does not have to happen right away. This includes the possibility that the work will be done sometime after your current process has terminated, because the user left your app and a lot of time passes before it is time to do your work.

However, there are scenarios for which WorkManager is optimized. Alternative scenarios might be better handled using other techniques:

Foreground services and AlarmManager are powerful techniques, but ones that we will not be exploring in this particular book. The Busy Coder’s Guide to Android Development, while older, offers material on those subjects.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.