DelegatingWorker

class DelegatingWorker(appContext: Context, workerParams: WorkerParameters) : CoroutineWorker(source)

A proxy Worker that delegates work to another CoroutineWorker created via HiltWorkerFactory.

WorkManager constructs this proxy, which reads the target class name from delegatedData, obtains HiltWorkerFactory through the application entry point, and creates the target. It forwards doWork and getForegroundInfo; this is not a general forwarding wrapper for every Worker lifecycle callback.

This project uses the proxy instead of installing a Hilt factory in WorkManager's configuration. Hilt also supports direct worker construction with a configured factory; see the official integration. Changing the initialization path requires a separately reviewed implementation.

Parameters

appContext

The application context provided by WorkManager

workerParams

The worker parameters containing input data with the delegate Worker class name

See also

Constructors

Link copied to clipboard
constructor(appContext: Context, workerParams: WorkerParameters)

Functions

Link copied to clipboard
open suspend override fun doWork(): ListenableWorker.Result

Delegates the actual work execution to the real Worker.

Link copied to clipboard
open suspend override fun getForegroundInfo(): ForegroundInfo

Delegates foreground info retrieval to the actual Worker.