RemoteListenableDelegatingWorker


public final class RemoteListenableDelegatingWorker extends ListenableWorker


A worker which can delegate to an instance of RemoteListenableWorker but importantly only constructs an instance of the RemoteListenableWorker in the remote process.

Summary

Public constructors

RemoteListenableDelegatingWorker(
    @NonNull Context context,
    @NonNull WorkerParameters workerParameters
)

Public methods

void

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

@NonNull ListenableFuture<@NonNull ListenableWorker.Result>

Override this method to start your actual background processing.

Inherited methods

From androidx.work.ListenableWorker
final @NonNull Context

Gets the application android.content.Context.

@NonNull ListenableFuture<@NonNull 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<@NonNull String>

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

final @NonNull List<@NonNull String>

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

final @NonNull List<@NonNull 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.

final @NonNull ListenableFuture<@NonNull Void>

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

@NonNull ListenableFuture<@NonNull Void>

Updates ListenableWorker progress.

Public constructors

RemoteListenableDelegatingWorker

public RemoteListenableDelegatingWorker(
    @NonNull Context context,
    @NonNull WorkerParameters workerParameters
)

Public methods

onStopped

public void onStopped()

This method is invoked when this Worker has been told to stop. At this point, the com.google.common.util.concurrent.ListenableFuture returned by the instance of startWork is also cancelled. This could happen due to an explicit cancellation signal by the user, or because the system has decided to preempt the task. In these cases, the results of the work will be ignored by WorkManager. All processing in this method should be lightweight - there are no contractual guarantees about which thread will invoke this call, so this should not be a long-running or blocking operation.

startWork

public @NonNull ListenableFuture<@NonNull ListenableWorker.ResultstartWork()

Override this method to start your actual background processing. This method is called on the main thread.

A ListenableWorker has a well defined execution window to to finish its execution and return a Result. After this time has expired, the worker will be signalled to stop and its com.google.common.util.concurrent.ListenableFuture will be cancelled.

The future will also be cancelled if this worker is stopped for any reason (see onStopped).

Returns
@NonNull ListenableFuture<@NonNull ListenableWorker.Result>

A com.google.common.util.concurrent.ListenableFuture with the Result of the computation. If you cancel this Future, WorkManager will treat this unit of work as failed.