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

Gets the ID of the WorkRequest that created this ListenableWorker.

@NonNull Data

Gets the input data.

@Nullable 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.

@NonNull Set<String>

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

@NonNull List<String>

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

@NonNull List<Uri>

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

Public methods

getGeneration

Added in 2.8.0
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

Added in 1.0.0
public @NonNull UUID getId()

Gets the ID of the WorkRequest that created this ListenableWorker.

Returns
@NonNull UUID

The ID of the creating WorkRequest

getInputData

Added in 1.0.0
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.

Returns
@NonNull Data

The input data for this work

See also
setInputMerger

getNetwork

Added in 1.0.0
@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 android.net.Network specified by the OS to be used with this Worker

getRunAttemptCount

Added in 1.0.0
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

Added in 1.0.0
public @NonNull Set<StringgetTags()

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

Returns
@NonNull Set<String>

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

See also
addTag

getTriggeredContentAuthorities

Added in 1.0.0
@RequiresApi(value = 24)
public @NonNull List<StringgetTriggeredContentAuthorities()

Gets the list of content authorities that caused this Worker to execute. See JobParameters#getTriggeredContentAuthorities() for relevant JobScheduler code.

Returns
@NonNull List<String>

The list of content authorities that caused this Worker to execute

getTriggeredContentUris

Added in 1.0.0
@RequiresApi(value = 24)
public @NonNull List<UrigetTriggeredContentUris()

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 android.net.Uris that caused this Worker to execute