# Print output for @column tags ?> JobInfo - Android SDK | Android Developers

Most visited

Recently visited

JobInfo

public class JobInfo
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.job.JobInfo


Container of data passed to the JobScheduler fully encapsulating the parameters required to schedule work against the calling application. These are constructed using the JobInfo.Builder. The goal here is to provide the scheduler with high-level semantics about the work you want to accomplish.

Prior to Android version Build.VERSION_CODES#Q, you had to specify at least one constraint on the JobInfo object that you are creating. Otherwise, the builder would throw an exception when building. From Android version Build.VERSION_CODES#Q and onwards, it is valid to schedule jobs with no constraints.

Summary

Nested classes

class JobInfo.Builder

Builder class for constructing JobInfo objects. 

class JobInfo.TriggerContentUri

Information about a content URI modification that a job would like to trigger on. 

Constants

int BACKOFF_POLICY_EXPONENTIAL

Exponentially back-off a failed job.

int BACKOFF_POLICY_LINEAR

Linearly back-off a failed job.

long DEFAULT_INITIAL_BACKOFF_MILLIS

Amount of backoff a job has initially by default, in milliseconds.

long MAX_BACKOFF_DELAY_MILLIS

Maximum backoff we allow for a job, in milliseconds.

int NETWORK_BYTES_UNKNOWN

Sentinel value indicating that bytes are unknown.

int NETWORK_TYPE_ANY

This job requires network connectivity.

int NETWORK_TYPE_CELLULAR

This job requires network connectivity that is a cellular network.

int NETWORK_TYPE_METERED

This constant is deprecated. Cellular networks may be unmetered, or Wi-Fi networks may be metered, so this isn't a good way of selecting a specific transport. Instead, use NETWORK_TYPE_CELLULAR or NetworkRequest.Builder.addTransportType(int) if your job requires a specific network transport.

int NETWORK_TYPE_NONE

Default.

int NETWORK_TYPE_NOT_ROAMING

This job requires network connectivity that is not roaming.

int NETWORK_TYPE_UNMETERED

This job requires network connectivity that is unmetered.

Inherited constants

Fields

public static final Creator<JobInfo> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

boolean equals(Object o)

Indicates whether some other object is "equal to" this one.

int getBackoffPolicy()

Return the backoff policy of this job.

ClipData getClipData()
int getClipGrantFlags()
long getEstimatedNetworkDownloadBytes()

Return the estimated size of download traffic that will be performed by this job, in bytes.

long getEstimatedNetworkUploadBytes()

Return the estimated size of upload traffic that will be performed by this job, in bytes.

PersistableBundle getExtras()
long getFlexMillis()

Flex time for this job.

int getId()

Unique job id associated with this application (uid).

long getInitialBackoffMillis()

The amount of time the JobScheduler will wait before rescheduling a failed job.

long getIntervalMillis()

Set to the interval between occurrences of this job.

long getMaxExecutionDelayMillis()
static final long getMinFlexMillis()

Query the minimum flex time allowed for periodic scheduled jobs.

long getMinLatencyMillis()

Set for a job that does not recur periodically, to specify a delay after which the job will be eligible for execution.

static final long getMinPeriodMillis()

Query the minimum interval allowed for periodic scheduled jobs.

int getNetworkType()

This method is deprecated. This method attempts to map getRequiredNetwork() into the set of simple constants, which results in a loss of fidelity. Callers should move to using getRequiredNetwork() directly.

NetworkRequest getRequiredNetwork()

Return the detailed description of the kind of network this job requires, or null if no specific kind of network is required.

ComponentName getService()

Name of the service endpoint that will be called back into by the JobScheduler.

Bundle getTransientExtras()
long getTriggerContentMaxDelay()

When triggering on content URI changes, this is the maximum delay we will use before scheduling the job.

long getTriggerContentUpdateDelay()

When triggering on content URI changes, this is the delay from when a change is detected until the job is scheduled.

TriggerContentUri[] getTriggerContentUris()

Which content: URIs must change for the job to be scheduled.

int hashCode()

Returns a hash code value for the object.

boolean isImportantWhileForeground()
boolean isPeriodic()

Track whether this job will repeat with a given period.

boolean isPersisted()
boolean isPrefetch()
boolean isRequireBatteryNotLow()
boolean isRequireCharging()
boolean isRequireDeviceIdle()
boolean isRequireStorageNotLow()
String toString()

Returns a string representation of the object.

void writeToParcel(Parcel out, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

BACKOFF_POLICY_EXPONENTIAL

public static final int BACKOFF_POLICY_EXPONENTIAL

Exponentially back-off a failed job. See JobInfo.Builder.setBackoffCriteria(long, int) retry_time(current_time, num_failures) = current_time + initial_backoff_millis * 2 ^ (num_failures - 1), num_failures >= 1

Constant Value: 1 (0x00000001)

BACKOFF_POLICY_LINEAR

public static final int BACKOFF_POLICY_LINEAR

Linearly back-off a failed job. See JobInfo.Builder.setBackoffCriteria(long, int) retry_time(current_time, num_failures) = current_time + initial_backoff_millis * num_failures, num_failures >= 1

Constant Value: 0 (0x00000000)

DEFAULT_INITIAL_BACKOFF_MILLIS

public static final long DEFAULT_INITIAL_BACKOFF_MILLIS

Amount of backoff a job has initially by default, in milliseconds.

Constant Value: 30000 (0x0000000000007530)

MAX_BACKOFF_DELAY_MILLIS

public static final long MAX_BACKOFF_DELAY_MILLIS

Maximum backoff we allow for a job, in milliseconds.

Constant Value: 18000000 (0x000000000112a880)

NETWORK_BYTES_UNKNOWN

public static final int NETWORK_BYTES_UNKNOWN

Sentinel value indicating that bytes are unknown.

Constant Value: -1 (0xffffffff)

NETWORK_TYPE_ANY

public static final int NETWORK_TYPE_ANY

This job requires network connectivity.

Constant Value: 1 (0x00000001)

NETWORK_TYPE_CELLULAR

public static final int NETWORK_TYPE_CELLULAR

This job requires network connectivity that is a cellular network.

Constant Value: 4 (0x00000004)

NETWORK_TYPE_METERED

public static final int NETWORK_TYPE_METERED

This constant is deprecated.
Cellular networks may be unmetered, or Wi-Fi networks may be metered, so this isn't a good way of selecting a specific transport. Instead, use NETWORK_TYPE_CELLULAR or NetworkRequest.Builder.addTransportType(int) if your job requires a specific network transport.

This job requires metered connectivity such as most cellular data networks.

Constant Value: 4 (0x00000004)

NETWORK_TYPE_NONE

public static final int NETWORK_TYPE_NONE

Default.

Constant Value: 0 (0x00000000)

NETWORK_TYPE_NOT_ROAMING

public static final int NETWORK_TYPE_NOT_ROAMING

This job requires network connectivity that is not roaming.

Constant Value: 3 (0x00000003)

NETWORK_TYPE_UNMETERED

public static final int NETWORK_TYPE_UNMETERED

This job requires network connectivity that is unmetered.

Constant Value: 2 (0x00000002)

Fields

CREATOR

public static final Creator<JobInfo> CREATOR

Public methods

describeContents

public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

equals

public boolean equals (Object o)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
o Object: the reference object with which to compare.

Returns
boolean true if this object is the same as the obj argument; false otherwise.

getBackoffPolicy

public int getBackoffPolicy ()

Return the backoff policy of this job.

Returns
int Value is BACKOFF_POLICY_LINEAR, or BACKOFF_POLICY_EXPONENTIAL

See also:

getClipData

public ClipData getClipData ()

Returns
ClipData This value may be null.

See also:

getClipGrantFlags

public int getClipGrantFlags ()

Returns
int

See also:

getEstimatedNetworkDownloadBytes

public long getEstimatedNetworkDownloadBytes ()

Return the estimated size of download traffic that will be performed by this job, in bytes.
Value is a non-negative number of bytes.

Returns
long Estimated size of download traffic, or NETWORK_BYTES_UNKNOWN when unknown. Value is a non-negative number of bytes.

See also:

getEstimatedNetworkUploadBytes

public long getEstimatedNetworkUploadBytes ()

Return the estimated size of upload traffic that will be performed by this job, in bytes.
Value is a non-negative number of bytes.

Returns
long Estimated size of upload traffic, or NETWORK_BYTES_UNKNOWN when unknown. Value is a non-negative number of bytes.

See also:

getExtras

public PersistableBundle getExtras ()

Returns
PersistableBundle This value cannot be null.

See also:

getFlexMillis

public long getFlexMillis ()

Flex time for this job. Only valid if this is a periodic job. The job can execute at any time in a window of flex length at the end of the period.

Returns
long

See also:

getId

public int getId ()

Unique job id associated with this application (uid). This is the same job ID you supplied in the Builder constructor.

Returns
int

getInitialBackoffMillis

public long getInitialBackoffMillis ()

The amount of time the JobScheduler will wait before rescheduling a failed job. This value will be increased depending on the backoff policy specified at job creation time. Defaults to 30 seconds, minimum is currently 10 seconds.

Returns
long

See also:

getIntervalMillis

public long getIntervalMillis ()

Set to the interval between occurrences of this job. This value is not set if the job does not recur periodically.

Returns
long

See also:

getMaxExecutionDelayMillis

public long getMaxExecutionDelayMillis ()

Returns
long

See also:

getMinFlexMillis

public static final long getMinFlexMillis ()

Query the minimum flex time allowed for periodic scheduled jobs. Attempting to declare a shorter flex time than this when scheduling such a job will result in this amount as the effective flex time for the job.

Returns
long The minimum available flex time for scheduling periodic jobs, in milliseconds.

getMinLatencyMillis

public long getMinLatencyMillis ()

Set for a job that does not recur periodically, to specify a delay after which the job will be eligible for execution. This value is not set if the job recurs periodically.

Returns
long

See also:

getMinPeriodMillis

public static final long getMinPeriodMillis ()

Query the minimum interval allowed for periodic scheduled jobs. Attempting to declare a smaller period than this when scheduling a job will result in a job that is still periodic, but will run with this effective period.

Returns
long The minimum available interval for scheduling periodic jobs, in milliseconds.

getNetworkType

public int getNetworkType ()

This method is deprecated.
This method attempts to map getRequiredNetwork() into the set of simple constants, which results in a loss of fidelity. Callers should move to using getRequiredNetwork() directly.

Return the basic description of the kind of network this job requires.

Returns
int Value is NETWORK_TYPE_NONE, NETWORK_TYPE_ANY, NETWORK_TYPE_UNMETERED, NETWORK_TYPE_NOT_ROAMING, or NETWORK_TYPE_CELLULAR

See also:

getRequiredNetwork

public NetworkRequest getRequiredNetwork ()

Return the detailed description of the kind of network this job requires, or null if no specific kind of network is required.

Returns
NetworkRequest

See also:

getService

public ComponentName getService ()

Name of the service endpoint that will be called back into by the JobScheduler.

Returns
ComponentName This value cannot be null.

getTransientExtras

public Bundle getTransientExtras ()

Returns
Bundle This value cannot be null.

See also:

getTriggerContentMaxDelay

public long getTriggerContentMaxDelay ()

When triggering on content URI changes, this is the maximum delay we will use before scheduling the job.

Returns
long

See also:

getTriggerContentUpdateDelay

public long getTriggerContentUpdateDelay ()

When triggering on content URI changes, this is the delay from when a change is detected until the job is scheduled.

Returns
long

See also:

getTriggerContentUris

public TriggerContentUri[] getTriggerContentUris ()

Which content: URIs must change for the job to be scheduled. Returns null if there are none required.

Returns
TriggerContentUri[]

See also:

hashCode

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

Returns
int a hash code value for this object.

isImportantWhileForeground

public boolean isImportantWhileForeground ()

Returns
boolean

See also:

isPeriodic

public boolean isPeriodic ()

Track whether this job will repeat with a given period.

Returns
boolean

See also:

isPersisted

public boolean isPersisted ()

Returns
boolean

See also:

isPrefetch

public boolean isPrefetch ()

Returns
boolean

See also:

isRequireBatteryNotLow

public boolean isRequireBatteryNotLow ()

Returns
boolean

See also:

isRequireCharging

public boolean isRequireCharging ()

Returns
boolean

See also:

isRequireDeviceIdle

public boolean isRequireDeviceIdle ()

Returns
boolean

See also:

isRequireStorageNotLow

public boolean isRequireStorageNotLow ()

Returns
boolean

See also:

toString

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

public void writeToParcel (Parcel out, 
                int flags)

Flatten this object in to a Parcel.

Parameters
out Parcel: The Parcel in which the object should be written.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES