Added in API level 34

Builder

class Builder
kotlin.Any
   ↳ android.app.job.JobWorkItem.Builder

Builder class for constructing JobWorkItem objects.

Summary

Public constructors

Initialize a new Builder to construct a JobWorkItem object.

Public methods
JobWorkItem

JobWorkItem.Builder
setEstimatedNetworkBytes(downloadBytes: Long, uploadBytes: Long)

Set the estimated size of network traffic that will be performed for this work item, in bytes.

JobWorkItem.Builder

Set optional extras.

JobWorkItem.Builder
setIntent(intent: Intent)

Set an intent with information relevant to this work item.

JobWorkItem.Builder

Set the minimum size of non-resumable network traffic this work item requires, in bytes.

Public constructors

Builder

Added in API level 34
Builder()

Initialize a new Builder to construct a JobWorkItem object.

Public methods

build

Added in API level 34
fun build(): JobWorkItem
Return
JobWorkItem The JobWorkItem object to hand to the JobScheduler. This object is immutable. This value cannot be null.

setEstimatedNetworkBytes

Added in API level 34
fun setEstimatedNetworkBytes(
    downloadBytes: Long,
    uploadBytes: Long
): JobWorkItem.Builder

Set the estimated size of network traffic that will be performed for this work item, in bytes. See JobInfo.Builder#setEstimatedNetworkBytes(long, long) for details about how to estimate network traffic.

Parameters
downloadBytes Long: The estimated size of network traffic that will be downloaded for this work item, in bytes. Value is a non-negative number of bytes.
uploadBytes Long: The estimated size of network traffic that will be uploaded for this work item, in bytes. Value is a non-negative number of bytes.
Return
JobWorkItem.Builder This object for method chaining This value cannot be null.

setExtras

Added in API level 34
fun setExtras(extras: PersistableBundle): JobWorkItem.Builder

Set optional extras. This can be persisted, so we only allow primitive types.

Parameters
extras PersistableBundle: Bundle containing extras you want the scheduler to hold on to for you. This value cannot be null.
Return
JobWorkItem.Builder This object for method chaining This value cannot be null.

setIntent

Added in API level 34
fun setIntent(intent: Intent): JobWorkItem.Builder

Set an intent with information relevant to this work item.

Intents cannot be used for persisted JobWorkItems. Use setExtras(android.os.PersistableBundle) instead for persisted JobWorkItems.

Parameters
intent Intent: This value cannot be null.
Return
JobWorkItem.Builder This object for method chaining This value cannot be null.

setMinimumNetworkChunkBytes

Added in API level 34
fun setMinimumNetworkChunkBytes(chunkSizeBytes: Long): JobWorkItem.Builder

Set the minimum size of non-resumable network traffic this work item requires, in bytes. When the upload or download can be easily paused and resumed, use this to set the smallest size that must be transmitted between start and stop events to be considered successful. If the transfer cannot be paused and resumed, then this should be the sum of the values provided to setEstimatedNetworkBytes(long,long). See JobInfo.Builder#setMinimumNetworkChunkBytes(long) for details about how to set the minimum chunk.

Parameters
chunkSizeBytes Long: The smallest piece of data that cannot be easily paused and resumed, in bytes. Value is a non-negative number of bytes.
Return
JobWorkItem.Builder This object for method chaining This value cannot be null.