Added in API level 26

JobWorkItem


class JobWorkItem : Parcelable
kotlin.Any
   ↳ android.app.job.JobWorkItem

A unit of work that can be enqueued for a job using JobScheduler.enqueue. See JobParameters.dequeueWork for more details.

Note: Prior to Android version android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE, JobWorkItems could not be persisted. Apps were not allowed to enqueue JobWorkItems with persisted jobs and the system would throw an IllegalArgumentException if they attempted to do so. Starting with android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE, JobWorkItems can be persisted alongside the hosting job. However, Intents cannot be persisted. Set a PersistableBundle using Builder#setExtras(PersistableBundle) for any information that needs to be persisted.

Summary

Nested classes

Builder class for constructing JobWorkItem objects.

Inherited constants
Public constructors
JobWorkItem(intent: Intent!)

Create a new piece of work, which can be submitted to JobScheduler.enqueue.

JobWorkItem(intent: Intent!, downloadBytes: Long, uploadBytes: Long)

Create a new piece of work, which can be submitted to JobScheduler.enqueue.

JobWorkItem(intent: Intent?, downloadBytes: Long, uploadBytes: Long, minimumChunkBytes: Long)

Create a new piece of work, which can be submitted to JobScheduler.enqueue.

Public methods
Int

Int

Return the count of the number of times this work item has been delivered to the job.

Long

Return the estimated size of download traffic that will be performed by this job, in bytes.

Long

Return the estimated size of upload traffic that will be performed by this job work item, in bytes.

PersistableBundle

Return the extras associated with this work.

Intent!

Return the Intent associated with this work.

Long

Return the smallest piece of data that cannot be easily paused and resumed, in bytes.

String

Unit
writeToParcel(out: Parcel, flags: Int)

Properties
static Parcelable.Creator<JobWorkItem!>

Public constructors

JobWorkItem

Added in API level 26
JobWorkItem(intent: Intent!)

Create a new piece of work, which can be submitted to JobScheduler.enqueue.

Intents cannot be used for persisted JobWorkItems. Use Builder#setExtras(PersistableBundle) instead for persisted JobWorkItems.

Parameters
intent Intent!: The general Intent describing this work.

JobWorkItem

Added in API level 28
JobWorkItem(
    intent: Intent!,
    downloadBytes: Long,
    uploadBytes: Long)

Create a new piece of work, which can be submitted to JobScheduler.enqueue.

See JobInfo.Builder#setEstimatedNetworkBytes(long, long) for details about how to estimate network traffic.

Intents cannot be used for persisted JobWorkItems. Use Builder#setExtras(PersistableBundle) instead for persisted JobWorkItems.

Parameters
intent Intent!: The general Intent describing this work.
downloadBytes Long: The estimated size of network traffic that will be downloaded by this job work item, in bytes. Value is a non-negative number of bytes.
uploadBytes Long: The estimated size of network traffic that will be uploaded by this job work item, in bytes. Value is a non-negative number of bytes.

JobWorkItem

Added in API level 33
JobWorkItem(
    intent: Intent?,
    downloadBytes: Long,
    uploadBytes: Long,
    minimumChunkBytes: Long)

Create a new piece of work, which can be submitted to JobScheduler.enqueue.

See JobInfo.Builder#setEstimatedNetworkBytes(long, long) for details about how to estimate network traffic.

Intents cannot be used for persisted JobWorkItems. Use Builder#setExtras(PersistableBundle) instead for persisted JobWorkItems.

Parameters
intent Intent?: The general Intent describing this work. This value may be null.
downloadBytes Long: The estimated size of network traffic that will be downloaded by this job work item, in bytes. Value is a non-negative number of bytes.
uploadBytes Long: The estimated size of network traffic that will be uploaded by this job work item, in bytes. Value is a non-negative number of bytes.
minimumChunkBytes Long: The smallest piece of data that cannot be easily paused and resumed, in bytes. Value is a non-negative number of bytes.

Public methods

describeContents

Added in API level 26
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

getDeliveryCount

Added in API level 26
fun getDeliveryCount(): Int

Return the count of the number of times this work item has been delivered to the job. The value will be > 1 if it has been redelivered because the job was stopped or crashed while it had previously been delivered but before the job had called JobParameters.completeWork for it.

getEstimatedNetworkDownloadBytes

Added in API level 28
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 JobInfo#NETWORK_BYTES_UNKNOWN when unknown. Value is a non-negative number of bytes.

getEstimatedNetworkUploadBytes

Added in API level 28
fun getEstimatedNetworkUploadBytes(): Long

Return the estimated size of upload traffic that will be performed by this job work item, in bytes.
Value is a non-negative number of bytes.

Return
Long Estimated size of upload traffic, or JobInfo#NETWORK_BYTES_UNKNOWN when unknown. Value is a non-negative number of bytes.

getExtras

Added in API level 34
fun getExtras(): PersistableBundle

Return the extras associated with this work.

Return
PersistableBundle This value cannot be null.

getIntent

Added in API level 26
fun getIntent(): Intent!

Return the Intent associated with this work.

getMinimumNetworkChunkBytes

Added in API level 33
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 JobInfo#NETWORK_BYTES_UNKNOWN when unknown. Value is a non-negative number of bytes.

toString

Added in API level 26
fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 26
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

Properties

CREATOR

Added in API level 26
static val CREATOR: Parcelable.Creator<JobWorkItem!>