androidWorkerFactory
The WorkerFactory to install in your WorkManager.Configuration. Compose with DelegatingWorkerFactory if you also use Hilt's HiltWorkerFactory or any other custom factory.
override val workManagerConfiguration: Configuration get() =
Configuration.Builder()
.setWorkerFactory(backgrounder.androidWorkerFactory())
.build()Content copied to clipboard
Or chained with Hilt:
Configuration.Builder()
.setWorkerFactory(DelegatingWorkerFactory().apply {
addFactory(hiltWorkerFactory)
addFactory(backgrounder.androidWorkerFactory())
})
.build()Content copied to clipboard
Throws
if this is not the live BackgroundTaskManager.shared instance (e.g. constructed directly via BackgroundTaskManager(engine) — not normally possible since the constructor is internal, but tests sometimes find a way).