Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

State

class State
kotlin.Any
   ↳ kotlin.Enum<androidx.work.WorkInfo.State>
   ↳ androidx.work.WorkInfo.State

The current lifecycle state of a WorkRequest.

Summary

Enum values

Used to indicate that the WorkRequest is currently blocked because its prerequisites haven't finished successfully.

Used to indicate that the WorkRequest has been cancelled and will not execute.

Used to indicate that the WorkRequest is enqueued and eligible to run when its Constraints are met and resources are available.

Used to indicate that the WorkRequest has completed in a failure state.

Used to indicate that the WorkRequest is currently being executed.

Used to indicate that the WorkRequest has completed in a successful state.

Public methods

Boolean

Returns true if this State is considered finished.

Enum values

BLOCKED

enum val BLOCKED : WorkInfo.State

Used to indicate that the WorkRequest is currently blocked because its prerequisites haven't finished successfully.

CANCELLED

enum val CANCELLED : WorkInfo.State

Used to indicate that the WorkRequest has been cancelled and will not execute. All dependent work will also be marked as CANCELLED and will not run.

ENQUEUED

enum val ENQUEUED : WorkInfo.State

Used to indicate that the WorkRequest is enqueued and eligible to run when its Constraints are met and resources are available.

FAILED

enum val FAILED : WorkInfo.State

Used to indicate that the WorkRequest has completed in a failure state. All dependent work will also be marked as FAILED and will never run.

RUNNING

enum val RUNNING : WorkInfo.State

Used to indicate that the WorkRequest is currently being executed.

SUCCEEDED

enum val SUCCEEDED : WorkInfo.State

Used to indicate that the WorkRequest has completed in a successful state. Note that PeriodicWorkRequests will never enter this state (they will simply go back to ENQUEUED and be eligible to run again).

Public methods

isFinished

fun isFinished(): Boolean

Returns true if this State is considered finished.

Return
Boolean: true for SUCCEEDED, FAILED, and * CANCELLED states