Skip to content

Most visited

Recently visited

navigation

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. You must specify at least one sort of constraint on the JobInfo object that you are creating. The goal here is to provide the scheduler with high-level semantics about the work you want to accomplish. Doing otherwise with throw an exception in your app.

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_TYPE_ANY

This job requires network connectivity.

int NETWORK_TYPE_METERED

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

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

From interface android.os.Parcelable

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()

ClipData of information that is returned to your application at execution time, but not persisted by the system.

int getClipGrantFlags()

Permission grants that go along with getClipData().

PersistableBundle getExtras()

Bundle of extras which are returned to your application at execution time.

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()

See setOverrideDeadline(long).

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()

The kind of connectivity requirements that the job has.

ComponentName getService()

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

Bundle getTransientExtras()

Bundle of transient extras which are returned to your application at execution time, but not persisted by the system.

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 isPeriodic()

Track whether this job will repeat with a given period.

boolean isPersisted()
boolean isRequireBatteryNotLow()

Whether this job needs the device's battery level to not be at below the critical threshold.

boolean isRequireCharging()

Whether this job needs the device to be plugged in.

boolean isRequireDeviceIdle()

Whether this job needs the device to be in an Idle maintenance window.

boolean isRequireStorageNotLow()

Whether this job needs the device's storage to not be low.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel out, int flags)

Flatten this object in to a Parcel.

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Constants

BACKOFF_POLICY_EXPONENTIAL

added in API level 21
int BACKOFF_POLICY_EXPONENTIAL

Exponentially back-off a failed job. See 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

added in API level 21
int BACKOFF_POLICY_LINEAR

Linearly back-off a failed job. See 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

added in API level 21
long DEFAULT_INITIAL_BACKOFF_MILLIS

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

Constant Value: 30000 (0x0000000000007530)

MAX_BACKOFF_DELAY_MILLIS

added in API level 21
long MAX_BACKOFF_DELAY_MILLIS

Maximum backoff we allow for a job, in milliseconds.

Constant Value: 18000000 (0x000000000112a880)

NETWORK_TYPE_ANY

added in API level 21
int NETWORK_TYPE_ANY

This job requires network connectivity.

Constant Value: 1 (0x00000001)

NETWORK_TYPE_METERED

int NETWORK_TYPE_METERED

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

Constant Value: 4 (0x00000004)

NETWORK_TYPE_NONE

added in API level 21
int NETWORK_TYPE_NONE

Default.

Constant Value: 0 (0x00000000)

NETWORK_TYPE_NOT_ROAMING

added in API level 24
int NETWORK_TYPE_NOT_ROAMING

This job requires network connectivity that is not roaming.

Constant Value: 3 (0x00000003)

NETWORK_TYPE_UNMETERED

added in API level 21
int NETWORK_TYPE_UNMETERED

This job requires network connectivity that is unmetered.

Constant Value: 2 (0x00000002)

Fields

CREATOR

added in API level 21
Creator<JobInfo> CREATOR

Public methods

describeContents

added in API level 21
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(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.

equals

added in API level 21
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

added in API level 21
int getBackoffPolicy ()

Return the backoff policy of this job.

Returns
int

Value is BACKOFF_POLICY_LINEAR or BACKOFF_POLICY_EXPONENTIAL.

getClipData

ClipData getClipData ()

ClipData of information that is returned to your application at execution time, but not persisted by the system.

Returns
ClipData

This value may be null.

getClipGrantFlags

int getClipGrantFlags ()

Permission grants that go along with getClipData().

Returns
int

getExtras

added in API level 21
PersistableBundle getExtras ()

Bundle of extras which are returned to your application at execution time.

Returns
PersistableBundle

This value will never be null.

getFlexMillis

added in API level 24
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

getId

added in API level 21
int getId ()

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

Returns
int

getInitialBackoffMillis

added in API level 21
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

getIntervalMillis

added in API level 21
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

getMaxExecutionDelayMillis

added in API level 21
long getMaxExecutionDelayMillis ()

See setOverrideDeadline(long). This value is not set if the job recurs periodically.

Returns
long

getMinFlexMillis

added in API level 24
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

added in API level 21
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

getMinPeriodMillis

added in API level 24
long getMinPeriodMillis ()

Query the minimum interval allowed for periodic scheduled jobs. Attempting to declare a smaller period that 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

added in API level 21
int getNetworkType ()

The kind of connectivity requirements that the job has.

Returns
int

Value is NETWORK_TYPE_NONE, NETWORK_TYPE_ANY, NETWORK_TYPE_UNMETERED, NETWORK_TYPE_NOT_ROAMING or NETWORK_TYPE_METERED.

getService

added in API level 21
ComponentName getService ()

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

Returns
ComponentName

This value will never be null.

getTransientExtras

Bundle getTransientExtras ()

Bundle of transient extras which are returned to your application at execution time, but not persisted by the system.

Returns
Bundle

This value will never be null.

getTriggerContentMaxDelay

added in API level 24
long getTriggerContentMaxDelay ()

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

Returns
long

getTriggerContentUpdateDelay

added in API level 24
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

getTriggerContentUris

added in API level 24
TriggerContentUri[] getTriggerContentUris ()

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

Returns
TriggerContentUri[]

This value may be null.

hashCode

added in API level 21
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.

isPeriodic

added in API level 21
boolean isPeriodic ()

Track whether this job will repeat with a given period.

Returns
boolean

isPersisted

added in API level 21
boolean isPersisted ()

Returns
boolean Whether or not this job should be persisted across device reboots.

isRequireBatteryNotLow

boolean isRequireBatteryNotLow ()

Whether this job needs the device's battery level to not be at below the critical threshold.

Returns
boolean

isRequireCharging

added in API level 21
boolean isRequireCharging ()

Whether this job needs the device to be plugged in.

Returns
boolean

isRequireDeviceIdle

added in API level 21
boolean isRequireDeviceIdle ()

Whether this job needs the device to be in an Idle maintenance window.

Returns
boolean

isRequireStorageNotLow

boolean isRequireStorageNotLow ()

Whether this job needs the device's storage to not be low.

Returns
boolean

toString

added in API level 21
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

added in API level 21
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_WRITE_RETURN_VALUE.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.