Android APIs
public class

JobInfo

extends Object
implements Parcelable
java.lang.Object
   ↳ android.app.job.JobInfo

Class Overview

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. 
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_UNMETERED This job requires network connectivity that is unmetered.
[Expand]
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's marshalled 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.
int getId()
Unique job id associated with this class.
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()
long getMinLatencyMillis()
Set for a job that does not recur periodically, to specify a delay after which the job will be eligible for execution.
int getNetworkType()
ComponentName getService()
Name of the service endpoint that will be called back into by the JobScheduler.
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 containing a concise, human-readable description of this object.
void writeToParcel(Parcel out, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final int BACKOFF_POLICY_EXPONENTIAL

Added in API level 21

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)

public static final int BACKOFF_POLICY_LINEAR

Added in API level 21

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)

public static final long DEFAULT_INITIAL_BACKOFF_MILLIS

Added in API level 21

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

Constant Value: 30000 (0x0000000000007530)

public static final long MAX_BACKOFF_DELAY_MILLIS

Added in API level 21

Maximum backoff we allow for a job, in milliseconds.

Constant Value: 18000000 (0x000000000112a880)

public static final int NETWORK_TYPE_ANY

Added in API level 21

This job requires network connectivity.

Constant Value: 1 (0x00000001)

public static final int NETWORK_TYPE_NONE

Added in API level 21

Default.

Constant Value: 0 (0x00000000)

public static final int NETWORK_TYPE_UNMETERED

Added in API level 21

This job requires network connectivity that is unmetered.

Constant Value: 2 (0x00000002)

Fields

public static final Creator<JobInfo> CREATOR

Added in API level 21

Public Methods

public int describeContents ()

Added in API level 21

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

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public int getBackoffPolicy ()

Added in API level 21

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

public PersistableBundle getExtras ()

Added in API level 21

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

public int getId ()

Added in API level 21

Unique job id associated with this class. This is assigned to your job by the scheduler.

public long getInitialBackoffMillis ()

Added in API level 21

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.

public long getIntervalMillis ()

Added in API level 21

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

public long getMaxExecutionDelayMillis ()

Added in API level 21

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

public long getMinLatencyMillis ()

Added in API level 21

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.

public int getNetworkType ()

Added in API level 21

public ComponentName getService ()

Added in API level 21

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

public boolean isPeriodic ()

Added in API level 21

Track whether this job will repeat with a given period.

public boolean isPersisted ()

Added in API level 21

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

public boolean isRequireCharging ()

Added in API level 21

Whether this job needs the device to be plugged in.

public boolean isRequireDeviceIdle ()

Added in API level 21

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

public String toString ()

Added in API level 21

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

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

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public void writeToParcel (Parcel out, int flags)

Added in API level 21

Flatten this object in to a Parcel.

Parameters
out The Parcel in which the object should be written.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.