Stay organized with collections Save and categorize content based on your preferences.

WorkInfo

public final class WorkInfo


Information about a particular WorkRequest containing the id of the WorkRequest, its current State, output, tags, and run attempt count. Note that output is only available for the terminal states (SUCCEEDED and FAILED).

Summary

Nested types

public enum WorkInfo.State

The current lifecycle state of a WorkRequest.

Public methods

boolean
int

Gets the latest generation of this Worker.

@NonNull UUID

Gets the identifier of the WorkRequest.

@NonNull Data

Gets the output Data for the WorkRequest.

@NonNull Data

Gets the progress Data associated with the WorkRequest.

@IntRange(from = 0) int

Gets the run attempt count of the WorkRequest.

@NonNull WorkInfo.State

Gets the current State of the WorkRequest.

@NonNull Set<String>

Gets the Set of tags associated with the WorkRequest.

int
String

Public methods

equals

public boolean equals(Object o)

getGeneration

public int getGeneration()

Gets the latest generation of this Worker.

A work has multiple generations, if it was updated via updateWork or enqueueUniquePeriodicWork using UPDATE.

If this worker is currently running, it can possibly be of an older generation rather than returned by this function if an update has happened during an execution of this worker.

Returns
int

a generation of this work.

getId

public @NonNull UUID getId()

Gets the identifier of the WorkRequest.

Returns
@NonNull UUID

The identifier of a WorkRequest

getOutputData

public @NonNull Data getOutputData()

Gets the output Data for the WorkRequest. If the WorkRequest is unfinished, this is always EMPTY.

Returns
@NonNull Data

The output Data of the WorkRequest

getProgress

public @NonNull Data getProgress()

Gets the progress Data associated with the WorkRequest.

Returns
@NonNull Data

The progress Data associated with the WorkRequest

getRunAttemptCount

public @IntRange(from = 0) int getRunAttemptCount()

Gets the run attempt count of the WorkRequest. Note that for PeriodicWorkRequests, the run attempt count gets reset between successful runs.

Returns
@IntRange(from = 0) int

The run attempt count of the WorkRequest.

getState

public @NonNull WorkInfo.State getState()

Gets the current State of the WorkRequest.

Returns
@NonNull WorkInfo.State

The current State of the WorkRequest

getTags

public @NonNull Set<StringgetTags()

Gets the Set of tags associated with the WorkRequest.

Returns
@NonNull Set<String>

The Set of tags associated with the WorkRequest

hashCode

public int hashCode()

toString

public String toString()