Register now for Android Dev Summit 2019!

DelegatingWorkerFactory

open class DelegatingWorkerFactory : WorkerFactory
kotlin.Any
   ↳ androidx.work.WorkerFactory
   ↳ androidx.work.DelegatingWorkerFactory

A WorkerFactory which delegates to other factories. Factories can register themselves as delegates, and they will be invoked in order until a delegated factory returns a non-null ListenableWorker instance.

Summary

Public constructors

Creates a new instance of the DelegatingWorkerFactory.

Public methods

Unit
addFactory(@NonNull workerFactory: WorkerFactory)

Adds a WorkerFactory to the list of delegates.

ListenableWorker?
createWorker(@NonNull context: Context, @NonNull workerClass: String, @NonNull parameters: WorkerParameters)

Public constructors

<init>

DelegatingWorkerFactory()

Creates a new instance of the DelegatingWorkerFactory.

Public methods

addFactory

fun addFactory(@NonNull workerFactory: WorkerFactory): Unit

Adds a WorkerFactory to the list of delegates.

Parameters
workerFactory WorkerFactory: The WorkerFactory instance.

createWorker

@Nullable fun createWorker(@NonNull context: Context, @NonNull workerClass: String, @NonNull parameters: WorkerParameters): ListenableWorker?