public class JobInfo extends Object implements Parcelable
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.Modifier and Type | Class and Description |
---|---|
static class |
JobInfo.Builder
Builder class for constructing
JobInfo objects. |
static class |
JobInfo.TriggerContentUri
Information about a content URI modification that a job would like to
trigger on.
|
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static int |
BACKOFF_POLICY_EXPONENTIAL
Exponentially back-off a failed job.
|
static int |
BACKOFF_POLICY_LINEAR
Linearly back-off a failed job.
|
static Parcelable.Creator<JobInfo> |
CREATOR |
static int |
DEFAULT_BACKOFF_POLICY
Default type of backoff.
|
static long |
DEFAULT_INITIAL_BACKOFF_MILLIS
Amount of backoff a job has initially by default, in milliseconds.
|
static int |
FLAG_WILL_BE_FOREGROUND
Indicates that the implementation of this job will be using
Service.startForeground(int, android.app.Notification) to run
in the foreground. |
static long |
MAX_BACKOFF_DELAY_MILLIS
Maximum backoff we allow for a job, in milliseconds.
|
static int |
NETWORK_TYPE_ANY
This job requires network connectivity.
|
static int |
NETWORK_TYPE_NONE
Default.
|
static int |
NETWORK_TYPE_NOT_ROAMING
This job requires network connectivity that is not roaming.
|
static int |
NETWORK_TYPE_UNMETERED
This job requires network connectivity that is unmetered.
|
static int |
PRIORITY_ADJ_ALWAYS_RUNNING
Adjustment of
getPriority() if the app has always (90% or more of the time)
been running jobs. |
static int |
PRIORITY_ADJ_OFTEN_RUNNING
Adjustment of
getPriority() if the app has often (50% or more of the time)
been running jobs. |
static int |
PRIORITY_DEFAULT
Default of
getPriority() . |
static int |
PRIORITY_FOREGROUND_APP
Value of
getPriority() for a foreground app (overrides the supplied
JobInfo priority if it is smaller). |
static int |
PRIORITY_SYNC_EXPEDITED
Value of
getPriority() for expedited syncs. |
static int |
PRIORITY_SYNC_INITIALIZATION
Value of
getPriority() for first time initialization syncs. |
static int |
PRIORITY_TOP_APP
Value of
getPriority() for the current top app (overrides the supplied
JobInfo priority if it is smaller). |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Modifier and Type | Method and Description |
---|---|
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.
|
int |
getFlags() |
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 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 long |
getMinPeriodMillis()
Query the minimum interval allowed for periodic scheduled jobs.
|
int |
getNetworkType()
|
int |
getPriority() |
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.
|
JobInfo.TriggerContentUri[] |
getTriggerContentUris()
Which content: URIs must change for the job to be scheduled.
|
boolean |
hasEarlyConstraint()
User can specify an early constraint of 0L, which is valid, so we keep track of whether the
function was called at all.
|
boolean |
hasLateConstraint()
User can specify a late constraint of 0L, which is valid, so we keep track of whether the
function was called at all.
|
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.
|
public static final int NETWORK_TYPE_NONE
public static final int NETWORK_TYPE_ANY
public static final int NETWORK_TYPE_UNMETERED
public static final int NETWORK_TYPE_NOT_ROAMING
public static final long DEFAULT_INITIAL_BACKOFF_MILLIS
public static final long MAX_BACKOFF_DELAY_MILLIS
public static final int BACKOFF_POLICY_LINEAR
JobInfo.Builder.setBackoffCriteria(long, int)
retry_time(current_time, num_failures) =
current_time + initial_backoff_millis * num_failures, num_failures >= 1public static final int BACKOFF_POLICY_EXPONENTIAL
JobInfo.Builder.setBackoffCriteria(long, int)
retry_time(current_time, num_failures) =
current_time + initial_backoff_millis * 2 ^ (num_failures - 1), num_failures >= 1public static final int DEFAULT_BACKOFF_POLICY
public static final int PRIORITY_DEFAULT
getPriority()
.public static final int PRIORITY_SYNC_EXPEDITED
getPriority()
for expedited syncs.public static final int PRIORITY_SYNC_INITIALIZATION
getPriority()
for first time initialization syncs.public static final int PRIORITY_FOREGROUND_APP
getPriority()
for a foreground app (overrides the supplied
JobInfo priority if it is smaller).public static final int PRIORITY_TOP_APP
getPriority()
for the current top app (overrides the supplied
JobInfo priority if it is smaller).public static final int PRIORITY_ADJ_OFTEN_RUNNING
getPriority()
if the app has often (50% or more of the time)
been running jobs.public static final int PRIORITY_ADJ_ALWAYS_RUNNING
getPriority()
if the app has always (90% or more of the time)
been running jobs.public static final int FLAG_WILL_BE_FOREGROUND
Service.startForeground(int, android.app.Notification)
to run
in the foreground.
When set, the internal scheduling of this job will ignore any background
network restrictions for the requesting app. Note that this flag alone
doesn't actually place your JobService
in the foreground; you
still need to post the notification yourself.
To use this flag, the caller must hold the
android.Manifest.permission#CONNECTIVITY_INTERNAL
permission.
public static final Parcelable.Creator<JobInfo> CREATOR
public static final long getMinPeriodMillis()
public static final long getMinFlexMillis()
public int getId()
JobInfo.Builder
constructor.public PersistableBundle getExtras()
public ComponentName getService()
public int getPriority()
public int getFlags()
public boolean isRequireCharging()
public boolean isRequireDeviceIdle()
public JobInfo.TriggerContentUri[] getTriggerContentUris()
public long getTriggerContentUpdateDelay()
public long getTriggerContentMaxDelay()
public int getNetworkType()
public long getMinLatencyMillis()
public long getMaxExecutionDelayMillis()
JobInfo.Builder.setOverrideDeadline(long)
. This value is not set if the job recurs
periodically.public boolean isPeriodic()
public boolean isPersisted()
public long getIntervalMillis()
public long getFlexMillis()
public long getInitialBackoffMillis()
public int getBackoffPolicy()
BACKOFF_POLICY_EXPONENTIAL
, or
BACKOFF_POLICY_LINEAR
, depending on which criteria you set
when creating this job.public boolean hasEarlyConstraint()
public boolean hasLateConstraint()
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel out, int flags)
Parcelable
writeToParcel
in interface Parcelable
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.PARCELABLE_WRITE_RETURN_VALUE
.public String toString()
Object
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())