WorkManager is the right tool for deferrable, guaranteed background work in Android. But the default setup pushes you toward boilerplate fast: you end up calling WorkManager.getInstance(context) inside ViewModels, passing Context where it doesn't belong, re-registering observers scattered across the codebase, and getting no consistent way to query the state of your enqueued work.

This tutorial shows how to build a clean, injectable WorkManagerHandler using Dagger Hilt, a single interface that any ViewModel can receive through constructor injection, with zero Context and a guaranteed WorkQuery callback on every call so you always know what to observe.

By the end, you'll have:

A WorkManager singleton provided through Hilt

A custom Configuration.Provider that plugs Hilt's HiltWorkerFactory into WorkManager at initialization