RemoteListenableDelegatingWorker
public final class RemoteListenableDelegatingWorker extends ListenableWorker
| java.lang.Object | ||
| ↳ | androidx.work.ListenableWorker | |
| ↳ | androidx.work.multiprocess.RemoteListenableDelegatingWorker |
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( |
Public methods |
|
|---|---|
@NonNull ListenableFuture<@NonNull ForegroundInfo> |
Return an instance of |
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 |
||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
RemoteListenableDelegatingWorker
public RemoteListenableDelegatingWorker(
@NonNull Context context,
@NonNull WorkerParameters workerParameters
)
Public methods
getForegroundInfoAsync
public @NonNull ListenableFuture<@NonNull ForegroundInfo> getForegroundInfoAsync()
Return an instance of ForegroundInfo if the WorkRequest is important to the user. In this case, WorkManager provides a signal to the OS that the process should be kept alive while this work is executing.
Prior to Android S, WorkManager manages and runs a foreground service on your behalf to execute the WorkRequest, showing the notification provided in the ForegroundInfo. To update this notification subsequently, the application can use android.app.NotificationManager.
Starting in Android S and above, WorkManager manages this WorkRequest using an immediate job.
| Returns | |
|---|---|
@NonNull ListenableFuture<@NonNull ForegroundInfo> |
A |
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.Result> startWork()
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 |