JobInfo
open class JobInfo : Parcelable
kotlin.Any | |
↳ | android.app.job.JobInfo |
Container of data passed to the android.app.job.JobScheduler
fully encapsulating the parameters required to schedule work against the calling application. These are constructed using the JobInfo.Builder
. The goal here is to provide the scheduler with high-level semantics about the work you want to accomplish.
Prior to Android version Build.VERSION_CODES.Q
, you had to specify at least one constraint on the JobInfo object that you are creating. Otherwise, the builder would throw an exception when building. From Android version Build.VERSION_CODES.Q
and onwards, it is valid to schedule jobs with no constraints.
Summary
Nested classes | |
---|---|
Builder class for constructing |
|
Information about a content URI modification that a job would like to trigger on. |
Constants | |
---|---|
static Int |
Exponentially back-off a failed job. |
static Int |
Linearly back-off a failed job. |
static Long |
Amount of backoff a job has initially by default, in milliseconds. |
static Long |
Maximum backoff we allow for a job, in milliseconds. |
static Int |
Sentinel value indicating that bytes are unknown. |
static Int |
This job requires network connectivity. |
static Int |
This job requires network connectivity that is a cellular network. |
static Int |
This job requires metered connectivity such as most cellular data networks. |
static Int |
Default. |
static Int |
This job requires network connectivity that is not roaming. |
static Int |
This job requires network connectivity that is unmetered. |
static Int |
Default value for all regular jobs. |
static Int |
This task should be ordered ahead of most other tasks. |
static Int |
Low priority. |
static Int |
This task is critical to user experience or functionality and should be run ahead of all other tasks. |
static Int |
Job has minimal value to the user. |
Inherited constants | |
---|---|
Public methods | |
---|---|
open Int | |
open Boolean | |
open Int |
Return the backoff policy of this job. |
open ClipData? | |
open Int | |
open MutableSet<String!> | |
open Long |
Return the estimated size of download traffic that will be performed by this job, in bytes. |
open Long |
Return the estimated size of upload traffic that will be performed by this job, in bytes. |
open PersistableBundle | |
open Long |
Flex time for this job. |
open Int |
getId() Unique job id associated with this application (uid). |
open Long |
The amount of time the JobScheduler will wait before rescheduling a failed job. |
open Long |
Set to the interval between occurrences of this job. |
open Long | |
static Long |
Query the minimum flex time allowed for periodic scheduled jobs. |
open Long |
Set for a job that does not recur periodically, to specify a delay after which the job will be eligible for execution. |
static Long |
Query the minimum interval allowed for periodic scheduled jobs. |
open Long |
Return the smallest piece of data that cannot be easily paused and resumed, in bytes. |
open Int |
Return the basic description of the kind of network this job requires. |
open Int | |
open NetworkRequest? |
Return the detailed description of the kind of network this job requires, or |
open ComponentName |
Name of the service endpoint that will be called back into by the JobScheduler. |
open String? | |
open Bundle | |
open Long |
When triggering on content URI changes, this is the maximum delay we will use before scheduling the job. |
open Long |
When triggering on content URI changes, this is the delay from when a change is detected until the job is scheduled. |
open Array<JobInfo.TriggerContentUri!>? |
Which content: URIs must change for the job to be scheduled. |
open Int |
hashCode() |
open Boolean | |
open Boolean |
Note: Beginning with android. |
open Boolean |
Track whether this job will repeat with a given period. |
open Boolean | |
open Boolean | |
open Boolean | |
open Boolean | |
open Boolean | |
open Boolean | |
open Boolean | |
open String |
toString() |
open Unit |
writeToParcel(out: Parcel, flags: Int) |
Properties | |
---|---|
static Parcelable.Creator<JobInfo!> |
Constants
BACKOFF_POLICY_EXPONENTIAL
static val BACKOFF_POLICY_EXPONENTIAL: Int
Exponentially back-off a failed job. See android.app.job.JobInfo.Builder#setBackoffCriteria(long, int)
retry_time(current_time, num_failures) = current_time + initial_backoff_millis * 2 ^ (num_failures - 1), num_failures >= 1
Value: 1
BACKOFF_POLICY_LINEAR
static val BACKOFF_POLICY_LINEAR: Int
Linearly back-off a failed job. See android.app.job.JobInfo.Builder#setBackoffCriteria(long, int)
retry_time(current_time, num_failures) = current_time + initial_backoff_millis * num_failures, num_failures >= 1
Value: 0
DEFAULT_INITIAL_BACKOFF_MILLIS
static val DEFAULT_INITIAL_BACKOFF_MILLIS: Long
Amount of backoff a job has initially by default, in milliseconds.
Value: 30000L
MAX_BACKOFF_DELAY_MILLIS
static val MAX_BACKOFF_DELAY_MILLIS: Long
Maximum backoff we allow for a job, in milliseconds.
Value: 18000000L
NETWORK_BYTES_UNKNOWN
static val NETWORK_BYTES_UNKNOWN: Int
Sentinel value indicating that bytes are unknown.
Value: -1
NETWORK_TYPE_ANY
static val NETWORK_TYPE_ANY: Int
This job requires network connectivity.
Value: 1
NETWORK_TYPE_CELLULAR
static val NETWORK_TYPE_CELLULAR: Int
This job requires network connectivity that is a cellular network.
Value: 4
NETWORK_TYPE_METERED
static valNETWORK_TYPE_METERED: Int
Deprecated: Cellular networks may be unmetered, or Wi-Fi networks may be metered, so this isn't a good way of selecting a specific transport. Instead, use NETWORK_TYPE_CELLULAR
or android.net.NetworkRequest.Builder#addTransportType(int)
if your job requires a specific network transport.
This job requires metered connectivity such as most cellular data networks.
Value: 4
NETWORK_TYPE_NOT_ROAMING
static val NETWORK_TYPE_NOT_ROAMING: Int
This job requires network connectivity that is not roaming.
Value: 3
NETWORK_TYPE_UNMETERED
static val NETWORK_TYPE_UNMETERED: Int
This job requires network connectivity that is unmetered.
Value: 2
PRIORITY_DEFAULT
static val PRIORITY_DEFAULT: Int
Default value for all regular jobs. As noted in JobScheduler
, these jobs have a general execution time of 10 minutes. Receives the standard job management policy.
Value: 300
PRIORITY_HIGH
static val PRIORITY_HIGH: Int
This task should be ordered ahead of most other tasks. It may be deferred a little, but if it doesn't run at some point, the user may think something is wrong. Assuming all constraints remain satisfied (including ideal system load conditions), these jobs can have an execution time of at least 4 minutes. Setting all of your jobs to high priority will not be beneficial to your app and in fact may hurt its performance in the long run.
Value: 400
PRIORITY_LOW
static val PRIORITY_LOW: Int
Low priority. The task provides some benefit to users, but is not critical and is more of a nice-to-have. This is more important than minimum priority jobs and will be prioritized ahead of them, but may still be deferred in lieu of higher priority jobs. JobScheduler may decide to defer these tasks while there are higher priority tasks in order to ensure there is sufficient quota available for the higher priority tasks. A sample task of low priority: prefetching data the user hasn't requested
Value: 200
PRIORITY_MAX
static val PRIORITY_MAX: Int
This task is critical to user experience or functionality and should be run ahead of all other tasks. Only expedited jobs
and user-initiated jobs
can have this priority.
Example tasks of max priority:
- Receiving a text message and processing it to show a notification
- Downloading or uploading some content the user requested to transfer immediately
Value: 500
PRIORITY_MIN
static val PRIORITY_MIN: Int
Job has minimal value to the user. The user has absolutely no expectation or knowledge of this task and it has no bearing on the user's perception of the app whatsoever. JobScheduler may decide to defer these tasks while there are higher priority tasks in order to ensure there is sufficient quota available for the higher priority tasks. A sample task of min priority: uploading analytics
Value: 100
Public methods
describeContents
open fun describeContents(): Int
Return | |
---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
equals
open fun equals(other: Any?): Boolean
Parameters | |
---|---|
obj |
the reference object with which to compare. |
Return | |
---|---|
Boolean |
true if this object is the same as the obj argument; false otherwise. |
getBackoffPolicy
open fun getBackoffPolicy(): Int
Return the backoff policy of this job.
Return | |
---|---|
Int |
Value is android.app.job.JobInfo#BACKOFF_POLICY_LINEAR , or android.app.job.JobInfo#BACKOFF_POLICY_EXPONENTIAL |
getClipData
open fun getClipData(): ClipData?
Return | |
---|---|
ClipData? |
This value may be null . |
getDebugTags
open fun getDebugTags(): MutableSet<String!>
Return | |
---|---|
MutableSet<String!> |
This value cannot be null . |
getEstimatedNetworkDownloadBytes
open fun getEstimatedNetworkDownloadBytes(): Long
Return the estimated size of download traffic that will be performed by this job, in bytes.
Value is a non-negative number of bytes.
Return | |
---|---|
Long |
Estimated size of download traffic, or NETWORK_BYTES_UNKNOWN when unknown. Value is a non-negative number of bytes. |
getEstimatedNetworkUploadBytes
open fun getEstimatedNetworkUploadBytes(): Long
Return the estimated size of upload traffic that will be performed by this job, in bytes.
Value is a non-negative number of bytes.
Return | |
---|---|
Long |
Estimated size of upload traffic, or NETWORK_BYTES_UNKNOWN when unknown. Value is a non-negative number of bytes. |
getExtras
open fun getExtras(): PersistableBundle
Return | |
---|---|
PersistableBundle |
This value cannot be null . |
getFlexMillis
open fun getFlexMillis(): Long
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.
getId
open fun getId(): Int
Unique job id associated with this application (uid). This is the same job ID you supplied in the Builder
constructor.
getInitialBackoffMillis
open fun getInitialBackoffMillis(): Long
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.
getIntervalMillis
open fun getIntervalMillis(): Long
Set to the interval between occurrences of this job. This value is not set if the job does not recur periodically.
getMinFlexMillis
static fun getMinFlexMillis(): Long
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.
Return | |
---|---|
Long |
The minimum available flex time for scheduling periodic jobs, in milliseconds. |
getMinLatencyMillis
open fun getMinLatencyMillis(): Long
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.
getMinPeriodMillis
static fun getMinPeriodMillis(): Long
Query the minimum interval allowed for periodic scheduled jobs. Attempting to declare a smaller period than this when scheduling a job will result in a job that is still periodic, but will run with this effective period.
Return | |
---|---|
Long |
The minimum available interval for scheduling periodic jobs, in milliseconds. |
getMinimumNetworkChunkBytes
open fun getMinimumNetworkChunkBytes(): Long
Return the smallest piece of data that cannot be easily paused and resumed, in bytes.
Value is a non-negative number of bytes.
Return | |
---|---|
Long |
Smallest piece of data that cannot be easily paused and resumed, or NETWORK_BYTES_UNKNOWN when unknown. Value is a non-negative number of bytes. |
getNetworkType
open fungetNetworkType(): Int
Deprecated: This method attempts to map getRequiredNetwork()
into the set of simple constants, which results in a loss of fidelity. Callers should move to using getRequiredNetwork()
directly.
Return the basic description of the kind of network this job requires.
getPriority
open fun getPriority(): Int
getRequiredNetwork
open fun getRequiredNetwork(): NetworkRequest?
Return the detailed description of the kind of network this job requires, or null
if no specific kind of network is required.
getService
open fun getService(): ComponentName
Name of the service endpoint that will be called back into by the JobScheduler.
Return | |
---|---|
ComponentName |
This value cannot be null . |
getTraceTag
open fun getTraceTag(): String?
Return | |
---|---|
String? |
This value may be null . |
getTransientExtras
open fun getTransientExtras(): Bundle
Return | |
---|---|
Bundle |
This value cannot be null . |
getTriggerContentMaxDelay
open fun getTriggerContentMaxDelay(): Long
When triggering on content URI changes, this is the maximum delay we will use before scheduling the job.
getTriggerContentUpdateDelay
open fun getTriggerContentUpdateDelay(): Long
When triggering on content URI changes, this is the delay from when a change is detected until the job is scheduled.
getTriggerContentUris
open fun getTriggerContentUris(): Array<JobInfo.TriggerContentUri!>?
Which content: URIs must change for the job to be scheduled. Returns null if there are none required.
hashCode
open fun hashCode(): Int
Return | |
---|---|
Int |
a hash code value for this object. |
isImportantWhileForeground
open funisImportantWhileForeground(): Boolean
Deprecated: Use isExpedited()
instead.
Note: Beginning with android.os.Build.VERSION_CODES#B, this flag will be ignored and no longer function effectively, regardless of the calling app's target SDK version. Calling this method will always return false
.
isPeriodic
open fun isPeriodic(): Boolean
Track whether this job will repeat with a given period.
toString
open fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
open fun writeToParcel(
out: Parcel,
flags: Int
): Unit
Parameters | |
---|---|
dest |
The Parcel in which the object should be written. This value cannot be null . |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |