Most visited

Recently visited

Added in API level 21

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_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.

int getBackoffPolicy()

One of either BACKOFF_POLICY_EXPONENTIAL, or BACKOFF_POLICY_LINEAR, depending on which criteria you set when creating this job.

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

One of NETWORK_TYPE_ANY, NETWORK_TYPE_NONE, NETWORK_TYPE_UNMETERED, or NETWORK_TYPE_NOT_ROAMING.

ComponentName getService()

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

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.

boolean isPeriodic()

Track whether this job will repeat with a given period.

boolean isPersisted()
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.

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_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.

getBackoffPolicy

Added in API level 21
int getBackoffPolicy ()

One of either BACKOFF_POLICY_EXPONENTIAL, or BACKOFF_POLICY_LINEAR, depending on which criteria you set when creating this job.

Returns
int

getExtras

Added in API level 21
PersistableBundle getExtras ()

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

Returns
PersistableBundle

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

One of NETWORK_TYPE_ANY, NETWORK_TYPE_NONE, NETWORK_TYPE_UNMETERED, or NETWORK_TYPE_NOT_ROAMING.

Returns
int

getService

Added in API level 21
ComponentName getService ()

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

Returns
ComponentName

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[]

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.

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

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.

Hooray!