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 (State.SUCCEEDED and State.FAILED).

Summary

Public constructors

WorkInfo(
    @NonNull UUID id,
    @NonNull WorkInfo.State state,
    @NonNull Set<@NonNull String> tags,
    @NonNull Data outputData,
    @NonNull Data progress,
    int runAttemptCount,
    int generation,
    @NonNull Constraints constraints,
    long initialDelayMillis,
    WorkInfo.PeriodicityInfo periodicityInfo,
    long nextScheduleTimeMillis,
    int stopReason
)

Constants

STOP_REASON_APP_STANDBY

public static final int STOP_REASON_APP_STANDBY = 12

The current standby bucket requires that the job stop now.

STOP_REASON_DEVICE_STATE

public static final int STOP_REASON_DEVICE_STATE = 4

The device state (eg. Doze, battery saver, memory usage, etc) requires WorkManager to stop this worker.

STOP_REASON_ESTIMATED_APP_LAUNCH_TIME_CHANGED

public static final int STOP_REASON_ESTIMATED_APP_LAUNCH_TIME_CHANGED = 15

The system's estimate of when the app will be launched changed significantly enough to decide this worker shouldn't be running right now.

STOP_REASON_NOT_STOPPED

public static final int STOP_REASON_NOT_STOPPED

Additional stop reason, that is returned from WorkInfo.stopReason in cases when a worker in question wasn't stopped. E.g. when a worker was just enqueued, but didn't run yet.

STOP_REASON_PREEMPT

public static final int STOP_REASON_PREEMPT = 2

The job was stopped to run a higher priority job of the app.

STOP_REASON_QUOTA

public static final int STOP_REASON_QUOTA = 10

The app has consumed all of its current quota. Each app is assigned a quota of how much it can run workers within a certain time frame. The quota is informed, in part, by app standby buckets.

STOP_REASON_SYSTEM_PROCESSING

public static final int STOP_REASON_SYSTEM_PROCESSING = 14

The system is doing some processing that requires stopping this job.

STOP_REASON_TIMEOUT

public static final int STOP_REASON_TIMEOUT = 3

The worker used up its maximum execution time and timed out. Each individual worker has a maximum execution time limit, regardless of how much total quota the app has. See the note on JobScheduler for the execution time limits.

STOP_REASON_UNKNOWN

public static final int STOP_REASON_UNKNOWN

Stop reason that is used in cases when worker did stop, but the reason for this is unknown. For example, when the app abruptly stopped due to a crash or when a device suddenly ran out of the battery.

STOP_REASON_USER

public static final int STOP_REASON_USER = 13

The user stopped the job. This can happen either through force-stop, adb shell commands, uninstalling, or some other UI.

Public constructors

WorkInfo

public WorkInfo(
    @NonNull UUID id,
    @NonNull WorkInfo.State state,
    @NonNull Set<@NonNull String> tags,
    @NonNull Data outputData,
    @NonNull Data progress,
    int runAttemptCount,
    int generation,
    @NonNull Constraints constraints,
    long initialDelayMillis,
    WorkInfo.PeriodicityInfo periodicityInfo,
    long nextScheduleTimeMillis,
    int stopReason
)

Public methods

getNextScheduleTimeMillis

public final long getNextScheduleTimeMillis()

The earliest time this work is eligible to run next, if this work is State.ENQUEUED.

This is the earliest System.currentTimeMillis time that WorkManager would consider running this work, regardless of any other system. It only represents the time that the initialDelay, periodic configuration, and backoff criteria are considered to be met.

Work will almost never run at this time in the real world. This method is intended for use in scheduling tests or to check set schedules in app. Work run times are dependent on many factors like the underlying system scheduler, doze and power saving modes of the OS, and meeting any configured constraints. This is expected and is not considered a bug.

The returned value may be in the past if the work was not able to run at that time. It will be eligible to run any time after that time.

Defaults to Long.MAX_VALUE for all other states, including if the work is currently State.RUNNING or State.BLOCKED on prerequisite work.

Even if this value is set, the work may not be registered with the system scheduler if there are limited scheduling slots or other factors.

getStopReason

@RequiresApi(value = 31)
public final int getStopReason()

The reason why this worker was stopped on the previous run attempt.

For a worker being stopped, at first it should have attempted to run, i.e. its state should be == RUNNING and then ListenableWorker.onStopped should have been called, resulting in this worker's state going back WorkInfo.State.ENQUEUED. In this situation (runAttemptCount > 0 and state == ENQUEUED) this stopReason property could be checked to see for additional information. Please note, that this state (runAttemptCount > 0 and state == ENQUEUED) can happen not only because a worker was stopped, but also when a worker returns ListenableWorker.Result.retry(). In this situation this property will return STOP_REASON_NOT_STOPPED.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-01-30 UTC.