SupportWorker

abstract class SupportWorker(context: Context, workerParameters: WorkerParameters) : Worker

A class that performs work synchronously on a background thread provided by androidx.work.WorkManager.

Worker classes are instantiated at runtime by WorkManager and the androidx.work.Worker.doWork method is called on a pre-specified background thread (see androidx.work.Configuration.getExecutor). This method is for synchronous processing of your work, meaning that once you return from that method, the Worker is considered to be finished and will be destroyed. If you need to do your work asynchronously or call asynchronous APIs, you should use androidx.work.ListenableWorker.

In case the work is preempted for any reason, the same instance of Worker is not reused. This means that androidx.work.Worker.doWork is called exactly once per Worker instance. A new Worker is created if a unit of work needs to be rerun.

A Worker is given a maximum of ten minutes to finish its execution and return a androidx.work.ListenableWorker.Result. After this time has expired, the Worker will be signalled to stop.

Since

v0.9.X

Constructors

Link copied to clipboard
constructor(context: Context, workerParameters: WorkerParameters)

Functions

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

Override this method to do your actual background processing. This method is called on a background thread - you are required to synchronously do your work and return the androidx.work.ListenableWorker.Result from this method. Once you return from this method, the Worker is considered to have finished what its doing and will be destroyed. If you need to do your work asynchronously on a thread of your own choice, see androidx.work.ListenableWorker.

Link copied to clipboard
Link copied to clipboard
open 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
open fun onStopped()
Link copied to clipboard
fun setForegroundAsync(@NonNull foregroundInfo: ForegroundInfo): ListenableFuture<Void>
Link copied to clipboard
open fun setProgressAsync(@NonNull data: Data): ListenableFuture<Void>
Link copied to clipboard
Link copied to clipboard
override fun startWork(): ListenableFuture<ListenableWorker.Result>
Link copied to clipboard