WorkManagerScheduler.SchedulerWorker


public final class WorkManagerScheduler.SchedulerWorker extends Worker


A Worker that starts the target service if the requirements are met.

Summary

Public constructors

SchedulerWorker(Context context, WorkerParameters workerParams)

Public methods

ListenableWorker.Result

Override this method to do your actual background processing.

Inherited methods

From androidx.work.ListenableWorker
final @NonNull Context

Gets the application android.content.Context.

@NonNull ListenableFuture<ForegroundInfo>

Return an instance of ForegroundInfo if the WorkRequest is important to the user.

final @NonNull UUID

Gets the ID of the WorkRequest that created this Worker.

final @NonNull Data

Gets the input data.

final @Nullable Network
@RequiresApi(value = 28)
getNetwork()

Gets the android.net.Network to use for this Worker.

final @IntRange(from = 0) int

Gets the current run attempt count for this work.

final int
@RequiresApi(value = 31)
getStopReason()

Returns a reason why this worker has been stopped.

final @NonNull Set<String>

Gets a java.util.Set of tags associated with this Worker's WorkRequest.

final @NonNull List<String>

Gets the list of content authorities that caused this Worker to execute.

final @NonNull List<Uri>

Gets the list of content android.net.Uris that caused this Worker to execute.

final boolean

Returns true if this Worker has been told to stop.

void

This method is invoked when this Worker has been told to stop.

final @NonNull ListenableFuture<Void>

This specifies that the WorkRequest is long-running or otherwise important.

@NonNull ListenableFuture<Void>

Updates ListenableWorker progress.

abstract @NonNull ListenableFuture<ListenableWorker.Result>

Override this method to start your actual background processing.

From androidx.work.Worker
ForegroundInfo

An instance of ForegroundInfo if the WorkRequest is important to the user.

ListenableFuture<ForegroundInfo>

Return an instance of ForegroundInfo if the WorkRequest is important to the user.

final ListenableFuture<ListenableWorker.Result>

Override this method to start your actual background processing.

Public constructors

SchedulerWorker

public SchedulerWorker(Context context, WorkerParameters workerParams)

Public methods

doWork

public ListenableWorker.Result doWork()

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 ListenableWorker.

A Worker has a well defined execution window to finish its execution and return a androidx.work.ListenableWorker.Result. After this time has expired, the Worker will be signalled to stop.