WorkerParameters
public final class WorkerParameters
Setup parameters for a ListenableWorker.
Summary
Public methods |
|
|---|---|
@IntRange(from = 0) int |
Gets the generation of this Worker. |
@NonNull UUID |
getId()Gets the ID of the |
@NonNull Data |
Gets the input data. |
@Nullable Network |
@RequiresApi(value = 28)Gets the |
@IntRange(from = 0) int |
Gets the current run attempt count for this work. |
@NonNull Set<String> |
getTags()Gets a |
@NonNull List<String> |
@RequiresApi(value = 24)Gets the list of content authorities that caused this Worker to execute. |
@NonNull List<Uri> |
@RequiresApi(value = 24)Gets the list of content |
Extension functions |
|
|---|---|
final boolean |
|
final @NonNull WorkerParameters |
<T extends ListenableWorker> WorkerParametersExtensions.usingRemoteService(Returns a new instance of |
final @NonNull WorkerParameters |
WorkerParametersExtensions.usingRemoteService(Returns a new instance of |
Public methods
getGeneration
public @IntRange(from = 0) int getGeneration()
Gets the generation of this Worker.
A work has multiple generations, if it was updated via updateWork or enqueueUniquePeriodicWork using UPDATE. This worker can possibly be of an older generation rather than latest known, if an update has happened while this worker is running.
| Returns | |
|---|---|
@IntRange(from = 0) int |
a generation of this work. |
getId
public @NonNull UUID getId()
Gets the ID of the WorkRequest that created this ListenableWorker.
| Returns | |
|---|---|
@NonNull UUID |
The ID of the creating |
getInputData
public @NonNull Data getInputData()
Gets the input data. Note that in the case that there are multiple prerequisites for this ListenableWorker, the input data has been run through an InputMerger.
| See also | |
|---|---|
setInputMerger |
getNetwork
@RequiresApi(value = 28)
public @Nullable Network getNetwork()
Gets the android.net.Network to use for this Worker. This method returns null if there is no network needed for this work request.
| Returns | |
|---|---|
@Nullable Network |
The |
getRunAttemptCount
public @IntRange(from = 0) int getRunAttemptCount()
Gets the current run attempt count for this work. Note that for periodic work, this value gets reset between periods.
| Returns | |
|---|---|
@IntRange(from = 0) int |
The current run attempt count for this work. |
getTags
public @NonNull Set<String> getTags()
Gets a java.util.Set of tags associated with this Worker's WorkRequest.
| Returns | |
|---|---|
@NonNull Set<String> |
The |
| See also | |
|---|---|
addTag |
getTriggeredContentAuthorities
@RequiresApi(value = 24)
public @NonNull List<String> getTriggeredContentAuthorities()
Gets the list of content authorities that caused this Worker to execute. See JobParameters#getTriggeredContentAuthorities() for relevant JobScheduler code.
getTriggeredContentUris
@RequiresApi(value = 24)
public @NonNull List<Uri> getTriggeredContentUris()
Gets the list of content android.net.Uris that caused this Worker to execute. See
JobParameters#getTriggeredContentUris()} for relevant JobScheduler code.
| Returns | |
|---|---|
@NonNull List<Uri> |
The list of content |
| See also | |
|---|---|
addContentUriTrigger |
Extension functions
WorkerParametersExtensions.isRemoteWorkRequest
public final boolean WorkerParametersExtensions.isRemoteWorkRequest(
@NonNull WorkerParameters receiver
)
| Returns | |
|---|---|
boolean |
|
WorkerParametersExtensions.usingRemoteService
public final @NonNull WorkerParameters <T extends ListenableWorker> WorkerParametersExtensions.usingRemoteService(
@NonNull WorkerParameters receiver,
@NonNull ComponentName componentName
)
Returns a new instance of WorkerParameters representing a WorkRequest that can run in a process corresponding to the provided ComponentName.
| Parameters | |
|---|---|
<T extends ListenableWorker> |
The |
@NonNull ComponentName componentName |
The |
| Returns | |
|---|---|
@NonNull WorkerParameters |
A new instance of |
WorkerParametersExtensions.usingRemoteService
public final @NonNull WorkerParameters WorkerParametersExtensions.usingRemoteService(
@NonNull WorkerParameters receiver,
@NonNull String workerClassName,
@NonNull ComponentName componentName
)
Returns a new instance of WorkerParameters representing a WorkRequest that can run in a process corresponding to the provided ComponentName.
| Parameters | |
|---|---|
@NonNull String workerClassName |
The fully qualified class name of the |
@NonNull ComponentName componentName |
The |
| Returns | |
|---|---|
@NonNull WorkerParameters |
A new instance of |