RemoteListenableDelegatingWorker


class RemoteListenableDelegatingWorker : 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(
    context: Context,
    workerParameters: WorkerParameters
)

Public functions

open Unit

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

open ListenableFuture<ListenableWorker.Result>

Override this method to start your actual background processing.

Inherited functions

From androidx.work.ListenableWorker
Context

Gets the application android.content.Context.

open ListenableFuture<ForegroundInfo>

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

UUID

Gets the ID of the WorkRequest that created this Worker.

Data

Gets the input data.

Network?
@RequiresApi(value = 28)
getNetwork()

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

@IntRange(from = 0) Int

Gets the current run attempt count for this work.

Int
@RequiresApi(value = 31)
getStopReason()

Returns a reason why this worker has been stopped.

MutableSet<String>

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

MutableList<String>

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

MutableList<Uri>

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

Boolean

Returns true if this Worker has been told to stop.

ListenableFuture<Void>

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

open ListenableFuture<Void>

Updates ListenableWorker progress.

Public constructors

RemoteListenableDelegatingWorker

Added in 2.10.0
RemoteListenableDelegatingWorker(
    context: Context,
    workerParameters: WorkerParameters
)

Public functions

onStopped

open fun onStopped(): Unit

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

Added in 2.10.0
open fun startWork(): ListenableFuture<ListenableWorker.Result>

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