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 |
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 |
|---|
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 |
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()
|
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 | |
|---|---|
java.lang.Object
| |
android.os.Parcelable
| |
Constants
BACKOFF_POLICY_EXPONENTIAL
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
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
long DEFAULT_INITIAL_BACKOFF_MILLIS
Amount of backoff a job has initially by default, in milliseconds.
Constant Value: 30000 (0x0000000000007530)
MAX_BACKOFF_DELAY_MILLIS
long MAX_BACKOFF_DELAY_MILLIS
Maximum backoff we allow for a job, in milliseconds.
Constant Value: 18000000 (0x000000000112a880)
NETWORK_TYPE_ANY
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
int NETWORK_TYPE_NONE
Default.
Constant Value: 0 (0x00000000)
NETWORK_TYPE_NOT_ROAMING
int NETWORK_TYPE_NOT_ROAMING
This job requires network connectivity that is not roaming.
Constant Value: 3 (0x00000003)
NETWORK_TYPE_UNMETERED
int NETWORK_TYPE_UNMETERED
This job requires network connectivity that is unmetered.
Constant Value: 2 (0x00000002)
Fields
Public methods
describeContents
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
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 returntrue. - It is symmetric: for any non-null reference values
xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any non-null reference values
x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue. - It is consistent: for any non-null reference values
xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified. - For any non-null reference value
x,x.equals(null)should returnfalse.
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
int getBackoffPolicy ()
Return the backoff policy of this job.
| Returns | |
|---|---|
int |
Value is |
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 |
getClipGrantFlags
int getClipGrantFlags ()
Permission grants that go along with getClipData().
| Returns | |
|---|---|
int |
|
getExtras
PersistableBundle getExtras ()
Bundle of extras which are returned to your application at execution time.
| Returns | |
|---|---|
PersistableBundle |
This value will never be |
getFlexMillis
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
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
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
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
long getMaxExecutionDelayMillis ()
See setOverrideDeadline(long). This value is not set if the job recurs
periodically.
| Returns | |
|---|---|
long |
|
getMinFlexMillis
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
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
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
int getNetworkType ()
The kind of connectivity requirements that the job has.
| Returns | |
|---|---|
int |
Value is |
getService
ComponentName getService ()
Name of the service endpoint that will be called back into by the JobScheduler.
| Returns | |
|---|---|
ComponentName |
This value will never be |
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 |
getTriggerContentMaxDelay
long getTriggerContentMaxDelay ()
When triggering on content URI changes, this is the maximum delay we will use before scheduling the job.
| Returns | |
|---|---|
long |
|
getTriggerContentUpdateDelay
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
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 |
hashCode
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
hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons 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 thehashCodemethod 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 thehashCodemethod 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
boolean isPeriodic ()
Track whether this job will repeat with a given period.
| Returns | |
|---|---|
boolean |
|
isPersisted
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
boolean isRequireCharging ()
Whether this job needs the device to be plugged in.
| Returns | |
|---|---|
boolean |
|
isRequireDeviceIdle
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
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
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.
|