JobWorkItem.Builder


public static final class JobWorkItem.Builder
extends Object

java.lang.Object
   ↳ android.app.job.JobWorkItem.Builder


Builder class for constructing JobWorkItem objects.

Summary

Public constructors

Builder()

Initialize a new Builder to construct a JobWorkItem object.

Public methods

JobWorkItem build()
JobWorkItem.Builder setEstimatedNetworkBytes(long downloadBytes, long uploadBytes)

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

JobWorkItem.Builder setExtras(PersistableBundle extras)

Set optional extras.

JobWorkItem.Builder setIntent(Intent intent)

Set an intent with information relevant to this work item.

JobWorkItem.Builder setMinimumNetworkChunkBytes(long chunkSizeBytes)

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

Inherited methods

Public constructors

Builder

Added in API level 34
public Builder ()

Initialize a new Builder to construct a JobWorkItem object.

Public methods

build

Added in API level 34
public JobWorkItem build ()

Returns
JobWorkItem The JobWorkItem object to hand to the JobScheduler. This object is immutable. This value cannot be null.

setEstimatedNetworkBytes

Added in API level 34
public JobWorkItem.Builder setEstimatedNetworkBytes (long downloadBytes, 
                long uploadBytes)

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.

Returns
JobWorkItem.Builder This object for method chaining This value cannot be null.

setExtras

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

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.

Returns
JobWorkItem.Builder This object for method chaining This value cannot be null.

setIntent

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

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.

Returns
JobWorkItem.Builder This object for method chaining This value cannot be null.

setMinimumNetworkChunkBytes

Added in API level 34
public JobWorkItem.Builder setMinimumNetworkChunkBytes (long chunkSizeBytes)

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.

Returns
JobWorkItem.Builder This object for method chaining This value cannot be null.