DelegatingWorker

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

A worker that delegates sync to another CoroutineWorker constructed with a HiltWorkerFactory.

This allows for creating and using CoroutineWorker instances with extended arguments without having to provide a custom WorkManager configuration that the app module needs to utilize.

In other words, it allows for custom workers in a library module without having to own configuration of the WorkManager singleton.

Constructors

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

Properties

Link copied to clipboard
open val coroutineContext: CoroutineDispatcher

Functions

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

Delegates the work to the delegate worker

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

Retrieves the foreground info from the delegate worker

Link copied to clipboard
override fun getForegroundInfoAsync(): ListenableFuture<ForegroundInfo>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@RequiresApi(value = 31)
fun getStopReason(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
override fun onStopped()
Link copied to clipboard
suspend fun setForeground(foregroundInfo: ForegroundInfo)
Link copied to clipboard
fun setForegroundAsync(@NonNull foregroundInfo: ForegroundInfo): ListenableFuture
Link copied to clipboard
suspend fun setProgress(data: Data)
Link copied to clipboard
open fun setProgressAsync(@NonNull data: Data): ListenableFuture
Link copied to clipboard
Link copied to clipboard
override fun startWork(): ListenableFuture<ListenableWorker.Result>
Link copied to clipboard