Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.app.job.JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#) |

Builder class for constructing `https://developer.android.com/reference/kotlin/android/app/job/JobInfo` objects.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#Builder(kotlin.Int,%20android.content.ComponentName)(jobId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, jobService: https://developer.android.com/reference/kotlin/android/content/ComponentName.html#)` Initialize a new Builder to construct a `https://developer.android.com/reference/kotlin/android/app/job/JobInfo`. |

| Public methods ||
|---|---|
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#addDebugTag(kotlin.String)(tag: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Add a debug tag to help track what this job is for. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#addTriggerContentUri(android.app.job.JobInfo.TriggerContentUri)(uri: https://developer.android.com/reference/kotlin/android/app/job/JobInfo.TriggerContentUri)` Add a new content: URI that will be monitored with a `https://developer.android.com/reference/kotlin/android/database/ContentObserver.html#`, and will cause the job to execute if changed. |
| [JobInfo](https://developer.android.com/reference/kotlin/android/app/job/JobInfo)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#build()()` <br /> |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#removeDebugTag(kotlin.String)(tag: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Remove a tag set via `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#addDebugTag(kotlin.String)`. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setBackoffCriteria(kotlin.Long,%20kotlin.Int)(initialBackoffMillis: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html, backoffPolicy: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set up the back-off/retry policy. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setCategory(kotlin.Int)(category: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the category for this job. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setClipData(android.content.ClipData,%20kotlin.Int)(clip: https://developer.android.com/reference/kotlin/android/content/ClipData.html#?, grantFlags: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set a `https://developer.android.com/reference/kotlin/android/content/ClipData.html#` associated with this Job. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setEstimatedNetworkBytes(kotlin.Long,%20kotlin.Long)(downloadBytes: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html, uploadBytes: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Set the estimated size of network traffic that will be performed by this job, in bytes. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setExpedited(kotlin.Boolean)(expedited: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Setting this to true indicates that this job is important and needs to run as soon as possible with stronger guarantees than regular jobs. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setExtras(android.os.PersistableBundle)(extras: https://developer.android.com/reference/kotlin/android/os/PersistableBundle.html#)` Set optional extras. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setImportantWhileForeground(kotlin.Boolean)(importantWhileForeground: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Setting this to true indicates that this job is important while the scheduling app is in the foreground or on the temporary allowlist for background restrictions. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setMinimumLatency(kotlin.Long)(minLatencyMillis: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Specify that this job should be delayed by the provided amount of time. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setMinimumNetworkChunkBytes(kotlin.Long)(chunkSizeBytes: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Set the minimum size of non-resumable network traffic this job requires, in bytes. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setOverrideDeadline(kotlin.Long)(maxExecutionDelayMillis: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Set a deadline after which all other functional requested constraints will be ignored. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setPeriodic(kotlin.Long)(intervalMillis: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Specify that this job should recur with the provided interval, not more than once per period. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setPeriodic(kotlin.Long,%20kotlin.Long)(intervalMillis: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html, flexMillis: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Specify that this job should recur with the provided interval and flex. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setPersisted(kotlin.Boolean)(isPersisted: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Set whether or not to persist this job across device reboots. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setPrefetch(kotlin.Boolean)(prefetch: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Setting this to true indicates that this job is designed to prefetch content that will make a material improvement to the experience of the specific user of this device. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setPriority(kotlin.Int)(priority: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Indicate the priority for this job. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetwork(android.net.NetworkRequest)(networkRequest: https://developer.android.com/reference/kotlin/android/net/NetworkRequest.html#?)` Set detailed description of the kind of network your job requires. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetworkType(kotlin.Int)(networkType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set basic description of the kind of network your job requires. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiresBatteryNotLow(kotlin.Boolean)(batteryNotLow: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Specify that to run this job, the device's battery level must not be low. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiresCharging(kotlin.Boolean)(requiresCharging: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Specify that to run this job, the device must be charging (or be a non-battery-powered device connected to permanent power, such as Android TV devices). |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiresDeviceIdle(kotlin.Boolean)(requiresDeviceIdle: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` When set `true`, ensure that this job will not run if the device is in active use. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiresStorageNotLow(kotlin.Boolean)(storageNotLow: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Specify that to run this job, the device's available storage must not be low. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setTraceTag(kotlin.String)(traceTag: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Set a tag that will be used in `https://developer.android.com/reference/kotlin/android/os/Trace.html#`. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setTransientExtras(android.os.Bundle)(extras: https://developer.android.com/reference/kotlin/android/os/Bundle.html#)` Set optional transient extras. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setTriggerContentMaxDelay(kotlin.Long)(durationMs: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Set the maximum total delay (in milliseconds) that is allowed from the first time a content change is detected until the job is scheduled. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setTriggerContentUpdateDelay(kotlin.Long)(durationMs: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Set the delay (in milliseconds) from when a content change is detected until the job is scheduled. |
| [JobInfo.Builder](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#) | `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setUserInitiated(kotlin.Boolean)(userInitiated: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Indicates that this job is being scheduled to fulfill an explicit user request. |

## Public constructors

### Builder

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
Builder(
    jobId: Int, 
    jobService: ComponentName)
```

Initialize a new Builder to construct a `https://developer.android.com/reference/kotlin/android/app/job/JobInfo`.

| Parameters ||
|---|---|
| `jobId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Application-provided id for this job. Subsequent calls to cancel, or jobs created with the same jobId, will update the pre-existing job with the same id. This ID must be unique across all clients of the same uid (not just the same package). You will want to make sure this is a stable id across app updates, so probably not based on a resource ID. |
| `jobService` | [ComponentName](https://developer.android.com/reference/kotlin/android/content/ComponentName.html#): The endpoint that you implement that will receive the callback from the JobScheduler. This value cannot be `null`. |

## Public methods

### addDebugTag

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun addDebugTag(tag: String): JobInfo.Builder
```

Add a debug tag to help track what this job is for. The tags may show in debug dumps or app metrics. Do not put personally identifiable information (PII) in the tag.

Tags have the following requirements:

- Tags cannot be more than 127 characters.
- Since leading and trailing whitespace can lead to hard-to-debug issues, tags should not include leading or trailing whitespace. All tags will be `https://developer.android.com/reference/kotlin/java/lang/String.html#trim()`.
- An empty String (after trimming) is not allowed.
- Should not have personally identifiable information (PII).
- A job cannot have more than 32 tags.

| Parameters ||
|---|---|
| `tag` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): A debug tag that helps describe what the job is for. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#` | This object for method chaining. This value cannot be `null`. |

### addTriggerContentUri

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun addTriggerContentUri(uri: JobInfo.TriggerContentUri): JobInfo.Builder!
```

Add a new content: URI that will be monitored with a `https://developer.android.com/reference/kotlin/android/database/ContentObserver.html#`, and will cause the job to execute if changed. If you have any trigger content URIs associated with a job, it will not execute until there has been a change report for one or more of them.

Note that trigger URIs can not be used in combination with `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setPeriodic(kotlin.Long)` or `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setPersisted(kotlin.Boolean)`. To continually monitor for content changes, you need to schedule a new JobInfo using the same job ID and observing the same URIs in place of calling `https://developer.android.com/reference/kotlin/android/app/job/JobService#jobFinished(android.app.job.JobParameters,%20kotlin.Boolean)`. Remember that `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler#schedule(android.app.job.JobInfo)` stops a running job if it uses the same job ID, so only call it after you've finished processing the most recent changes (in other words, call `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler#schedule(android.app.job.JobInfo)` where you would have normally called `https://developer.android.com/reference/kotlin/android/app/job/JobService#jobFinished(android.app.job.JobParameters,%20kotlin.Boolean)`. Following this pattern will ensure you do not lose any content changes: while your job is running, the system will continue monitoring for content changes, and propagate any changes it sees over to the next job you schedule, so you do not have to worry about missing new changes. **Scheduling the new job before or during processing will cause the current job to be stopped (as described in `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler#schedule(android.app.job.JobInfo)`), meaning the wakelock will be released for the current job and your app process may be killed since it will no longer be in a valid component lifecycle.** Since `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler#schedule(android.app.job.JobInfo)` stops the current job, you do not need to call `https://developer.android.com/reference/kotlin/android/app/job/JobService#jobFinished(android.app.job.JobParameters,%20kotlin.Boolean)` if you call `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler#schedule(android.app.job.JobInfo)` using the same job ID as the currently running job.

Because setting this property is not compatible with periodic or persisted jobs, doing so will throw an `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#` when `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#build()` is called.

The following example shows how this feature can be used to monitor for changes in the photos on a device.

| Parameters ||
|---|---|
| `uri` | [JobInfo.TriggerContentUri](https://developer.android.com/reference/kotlin/android/app/job/JobInfo.TriggerContentUri): The content: URI to monitor. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getTriggerContentUris()`

### build

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun build(): JobInfo!
```

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo!` | The job object to hand to the JobScheduler. This object is immutable. |

### removeDebugTag

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun removeDebugTag(tag: String): JobInfo.Builder
```

Remove a tag set via `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#addDebugTag(kotlin.String)`.

| Parameters ||
|---|---|
| `tag` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The tag to remove. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#` | This object for method chaining. This value cannot be `null`. |

### setBackoffCriteria

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setBackoffCriteria(
    initialBackoffMillis: Long, 
    backoffPolicy: Int
): JobInfo.Builder!
```

Set up the back-off/retry policy. This defaults to some respectable values: {30 seconds, Exponential}. We cap back-off at 5hrs.

Note that trying to set a backoff criteria for a job with `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiresDeviceIdle(kotlin.Boolean)` will throw an exception when you call build(). This is because back-off typically does not make sense for these types of jobs. See `https://developer.android.com/reference/kotlin/android/app/job/JobService#jobFinished(android.app.job.JobParameters,%20kotlin.Boolean)` for more description of the return value for the case of a job executing while in idle mode.

| Parameters ||
|---|---|
| `initialBackoffMillis` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): Millisecond time interval to wait initially when job has failed. |
| `backoffPolicy` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#BACKOFF_POLICY_LINEAR:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#BACKOFF_POLICY_EXPONENTIAL:kotlin.Int` |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getInitialBackoffMillis()`
- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getBackoffPolicy()`

### setCategory

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setCategory(category: Int): JobInfo.Builder
```

Sets the category for this job.

The category provides a hint to the system about the purpose of the job, which may influence scheduling and quota allocation.

| Parameters ||
|---|---|
| `category` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The category for this job, e.g., `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#CATEGORY_APP_UPDATES:kotlin.Int`. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#CATEGORY_NONE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#CATEGORY_APP_UPDATES:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#` | This Builder object to allow for chaining of calls. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getCategory()`

### setClipData

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setClipData(
    clip: ClipData?, 
    grantFlags: Int
): JobInfo.Builder!
```

Set a `https://developer.android.com/reference/kotlin/android/content/ClipData.html#` associated with this Job.

The main purpose of providing a ClipData is to allow granting of URI permissions for data associated with the clip. The exact kind of permission grant to perform is specified through grantFlags.

If the ClipData contains items that are Intents, any grant flags in those Intents will be ignored. Only flags provided as an argument to this method are respected, and will be applied to all Uri or Intent items in the clip (or sub-items of the clip).

Because setting this property is not compatible with persisted jobs, doing so will throw an `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#` when `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#build()` is called.

| Parameters ||
|---|---|
| `clip` | [ClipData](https://developer.android.com/reference/kotlin/android/content/ClipData.html#)?: The new clip to set. May be null to clear the current clip. |
| `grantFlags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The desired permissions to grant for any URIs. This should be a combination of `https://developer.android.com/reference/kotlin/android/content/Intent.html#FLAG_GRANT_READ_URI_PERMISSION:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/content/Intent.html#FLAG_GRANT_WRITE_URI_PERMISSION:kotlin.Int`, and `https://developer.android.com/reference/kotlin/android/content/Intent.html#FLAG_GRANT_PREFIX_URI_PERMISSION:kotlin.Int`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getClipData()`
- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getClipGrantFlags()`

### setEstimatedNetworkBytes

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setEstimatedNetworkBytes(
    downloadBytes: Long, 
    uploadBytes: Long
): JobInfo.Builder!
```

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

Apps are encouraged to provide values that are as accurate as possible, but when the exact size isn't available, an order-of-magnitude estimate can be provided instead. Here are some specific examples:

- A job that is backing up a photo knows the exact size of that photo, so it should provide that size as the estimate.
- A job that refreshes top news stories wouldn't know an exact size, but if the size is expected to be consistently around 100KB, it can provide that order-of-magnitude value as the estimate.
- A job that synchronizes email could end up using an extreme range of data, from under 1KB when nothing has changed, to dozens of MB when there are new emails with attachments. Jobs that cannot provide reasonable estimates should use the sentinel value `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_BYTES_UNKNOWN:kotlin.Int`.

Note that the system may choose to delay jobs with large network usage estimates when the device has a poor network connection, in order to save battery and possible network costs. Starting from Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#S:kotlin.Int`, JobScheduler may attempt to run large jobs when the device is charging and on an unmetered network, even if the network is slow. This gives large jobs an opportunity to make forward progress, even if they risk timing out.

The values provided here only reflect the traffic that will be performed by the base job; if you're using `https://developer.android.com/reference/kotlin/android/app/job/JobWorkItem` then you also need to define the network traffic used by each work item when constructing them.

Prior to Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#TIRAMISU:kotlin.Int`, JobScheduler used the estimated transfer numbers in a similar fashion to `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setMinimumNetworkChunkBytes(kotlin.Long)` (to estimate if the work would complete within the time available to job). In other words, JobScheduler treated the transfer as all-or-nothing. Starting from Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#TIRAMISU:kotlin.Int`, JobScheduler will only use the estimated transfer numbers in this manner if minimum chunk sizes have not been provided via `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setMinimumNetworkChunkBytes(kotlin.Long)`.

| Parameters ||
|---|---|
| `downloadBytes` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): The estimated size of network traffic that will be downloaded by this job, in bytes. Value is a non-negative number of bytes. |
| `uploadBytes` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): The estimated size of network traffic that will be uploaded by this job, in bytes. Value is a non-negative number of bytes. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getEstimatedNetworkDownloadBytes()`
- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getEstimatedNetworkUploadBytes()`
- `https://developer.android.com/reference/kotlin/android/app/job/JobWorkItem#JobWorkItem(android.content.Intent,%20kotlin.Long,%20kotlin.Long)`

### setExpedited

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setExpedited(expedited: Boolean): JobInfo.Builder
```

Setting this to true indicates that this job is important and needs to run as soon as possible with stronger guarantees than regular jobs. These "expedited" jobs will:

1. Run as soon as possible
2. Be less restricted during Doze and battery saver
3. Bypass Doze, app standby, and battery saver network restrictions (if the job has a `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetwork(android.net.NetworkRequest)`)
4. Be less likely to be killed than regular jobs
5. Be subject to background location throttling
6. Be exempt from delay to optimize job execution

<br />

Expedited jobs are given `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#PRIORITY_MAX:kotlin.Int` by default.

Since these jobs have stronger guarantees than regular jobs, they will be subject to stricter quotas. As long as an app has available expedited quota, jobs scheduled with this set to true will run with these guarantees. If an app has run out of available expedited quota, any pending expedited jobs will run as regular jobs. `https://developer.android.com/reference/kotlin/android/app/job/JobParameters#isExpeditedJob()` can be used to know whether the executing job has expedited guarantees or not. In addition, `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler#schedule(android.app.job.JobInfo)` will immediately return `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler#RESULT_FAILURE:kotlin.Int` if the app does not have available quota (and the job will not be successfully scheduled).

Expedited job quota will replenish over time and as the user interacts with the app, so you should not have to worry about running out of quota because of processing from frequent user engagement.

Expedited jobs may only set network, storage-not-low, and persistence constraints. No other constraints are allowed.

Assuming all constraints remain satisfied (including ideal system load conditions), expedited jobs can have an execution time of at least 1 minute. If your app has remaining expedited job quota, then the expedited job *may* potentially run longer until remaining quota is used up. Just like with regular jobs, quota is not consumed while the app is on top and visible to the user.

Note: Even though expedited jobs are meant to run as soon as possible, they may be deferred if the system is under heavy load or requested constraints are not satisfied. This delay may be true for expedited jobs of the foreground app on Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#S:kotlin.Int`, but starting from Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#TIRAMISU:kotlin.Int`, expedited jobs for the foreground app are guaranteed to be started before `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler#schedule(android.app.job.JobInfo)` returns (assuming all requested constraints are satisfied), similar to foreground services.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#` | This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isExpedited()`

### setExtras

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setExtras(extras: PersistableBundle): JobInfo.Builder!
```

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

| Parameters ||
|---|---|
| `extras` | [PersistableBundle](https://developer.android.com/reference/kotlin/android/os/PersistableBundle.html#): Bundle containing extras you want the scheduler to hold on to for you. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getExtras()`

### setImportantWhileForeground

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setImportantWhileForeground(importantWhileForeground: Boolean): JobInfo.Builder!
```

**Deprecated:** *Use `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setExpedited(kotlin.Boolean)` instead.*

Setting this to true indicates that this job is important while the scheduling app is in the foreground or on the temporary allowlist for background restrictions. This means that the system will relax doze restrictions on this job during this time. Apps should use this flag only for short jobs that are essential for the app to function properly in the foreground. Note that once the scheduling app is no longer allowlisted from background restrictions and in the background, or the job failed due to unsatisfied constraints, this job should be expected to behave like other jobs without this flag.

Jobs marked as important-while-foreground are given `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#PRIORITY_HIGH:kotlin.Int` by default.

**Note:** Beginning with `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#BAKLAVA:kotlin.Int`, this flag will be ignored and no longer function effectively, regardless of the calling app's target SDK version. `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isImportantWhileForeground()` will always return `false`. Apps should use {link #setExpedited(boolean)} with `true` to indicate that this job is important and needs to run as soon as possible.

| Parameters ||
|---|---|
| `importantWhileForeground` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): whether to relax doze restrictions for this job when the app is in the foreground. False by default. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isImportantWhileForeground()`

### setMinimumLatency

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setMinimumLatency(minLatencyMillis: Long): JobInfo.Builder!
```

Specify that this job should be delayed by the provided amount of time. The job may not run the instant the delay has elapsed. JobScheduler will start the job at an indeterminate time after the delay has elapsed.

Because it doesn't make sense setting this property on a periodic job, doing so will throw an `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#` when `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#build()` is called. Negative latencies also don't make sense for a job and are indicative of an error, so starting in Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#VANILLA_ICE_CREAM:kotlin.Int`, setting a negative deadline will result in `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#build()` throwing an `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#`.

| Parameters ||
|---|---|
| `minLatencyMillis` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): Milliseconds before which this job will not be considered for execution. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getMinLatencyMillis()`

### setMinimumNetworkChunkBytes

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setMinimumNetworkChunkBytes(chunkSizeBytes: Long): JobInfo.Builder
```

Set the minimum size of non-resumable network traffic this job 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 `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setEstimatedNetworkBytes(kotlin.Long,%20kotlin.Long)`.

Apps are encouraged to provide values that are as accurate as possible since JobScheduler will try to run the job at a time when at least the minimum chunk can be transmitted to reduce the amount of repetitive data that's transferred. Jobs that cannot provide reasonable estimates should use the sentinel value `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_BYTES_UNKNOWN:kotlin.Int`.

The values provided here only reflect the minimum non-resumable traffic that will be performed by the base job; if you're using `https://developer.android.com/reference/kotlin/android/app/job/JobWorkItem` then you also need to define the network traffic used by each work item when constructing them.

| Parameters ||
|---|---|
| `chunkSizeBytes` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): The smallest piece of data that cannot be easily paused and resumed, in bytes. Value is a non-negative number of bytes. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#` | This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getMinimumNetworkChunkBytes()`
- `https://developer.android.com/reference/kotlin/android/app/job/JobWorkItem#JobWorkItem(android.content.Intent,%20kotlin.Long,%20kotlin.Long,%20kotlin.Long)`

### setOverrideDeadline

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setOverrideDeadline(maxExecutionDelayMillis: Long): JobInfo.Builder!
```

Set a deadline after which all other functional requested constraints will be ignored. After the deadline has passed, the job can run even if other requirements (including a delay set through `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setMinimumLatency(kotlin.Long)`) are not met. `https://developer.android.com/reference/kotlin/android/app/job/JobParameters#isOverrideDeadlineExpired()` will return `true` if the job's deadline has passed. The job's execution may be delayed beyond the set deadline by other factors such as Doze mode and system health signals.

Because it doesn't make sense setting this property on a periodic job, doing so will throw an `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#` when `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#build()` is called.

Negative deadlines also don't make sense for a job and are indicative of an error, so starting in Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#VANILLA_ICE_CREAM:kotlin.Int`, setting a negative deadline will result in `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#build()` throwing an `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#`.

Since a job will run once the deadline has passed regardless of the status of other constraints, setting a deadline of 0 (or a `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setMinimumLatency(kotlin.Long)` equal to the deadline) with other constraints makes those constraints meaningless when it comes to execution decisions. Since doing so is indicative of an error in the logic, starting in Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#VANILLA_ICE_CREAM:kotlin.Int`, jobs with extremely short time windows will fail to build. Time windows are defined as the time between a job's `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setMinimumLatency(kotlin.Long)` and its deadline. If the minimum latency is not set, it is assumed to be 0. Work that must happen immediately should use `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setExpedited(kotlin.Boolean)` or `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setUserInitiated(kotlin.Boolean)` in the appropriate manner.

This API aimed to guarantee execution of the job by the deadline only on Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#LOLLIPOP:kotlin.Int`. That aim and guarantee has not existed since `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#M:kotlin.Int`.
**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getMaxExecutionDelayMillis()`

### setPeriodic

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setPeriodic(intervalMillis: Long): JobInfo.Builder!
```

Specify that this job should recur with the provided interval, not more than once per period. You have no control over when within this interval this job will be executed, only the guarantee that it will be executed at most once within this interval, as long as the constraints are satisfied. If the constraints are not satisfied within this interval, the job will wait until the constraints are satisfied. Setting this function on the builder with `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setMinimumLatency(kotlin.Long)` or `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setOverrideDeadline(kotlin.Long)` will result in an error.

| Parameters ||
|---|---|
| `intervalMillis` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): Millisecond interval for which this job will repeat. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getIntervalMillis()`
- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getFlexMillis()`

### setPeriodic

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setPeriodic(
    intervalMillis: Long, 
    flexMillis: Long
): JobInfo.Builder!
```

Specify that this job should recur with the provided interval and flex. The job can execute at any time in a window of flex length at the end of the period. If the constraints are not satisfied within the window, the job will wait until the constraints are satisfied.

| Parameters ||
|---|---|
| `intervalMillis` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): Millisecond interval for which this job will repeat. A minimum value of `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getMinPeriodMillis()` is enforced. |
| `flexMillis` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): Millisecond flex for this job. Flex is clamped to be at least `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getMinFlexMillis()` or 5 percent of the period, whichever is higher. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getIntervalMillis()`
- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getFlexMillis()`

### setPersisted

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setPersisted(isPersisted: Boolean): JobInfo.Builder!
```

Set whether or not to persist this job across device reboots.   
Requires `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#RECEIVE_BOOT_COMPLETED:kotlin.String`

| Parameters ||
|---|---|
| `isPersisted` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): True to indicate that the job will be written to disk and loaded at boot. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isPersisted()`

### setPrefetch

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setPrefetch(prefetch: Boolean): JobInfo.Builder!
```

Setting this to true indicates that this job is designed to prefetch content that will make a material improvement to the experience of the specific user of this device. For example, fetching top headlines of interest to the current user.

Apps targeting Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#TIRAMISU:kotlin.Int` or later are not allowed to have deadlines (set via `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setOverrideDeadline(kotlin.Long)` on their prefetch jobs.

The system may use this signal to relax the network constraints you originally requested, such as allowing a `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_TYPE_UNMETERED:kotlin.Int` job to run over a metered network when there is a surplus of metered data available. The system may also use this signal in combination with end user usage patterns to ensure data is prefetched before the user launches your app.
**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isPrefetch()`

### setPriority

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setPriority(priority: Int): JobInfo.Builder
```

Indicate the priority for this job. The priority set here will be used to sort jobs for the calling app and apply slightly different policies based on the priority. The priority will **NOT** be used as a global sorting value to sort between different app's jobs. Use this to inform the system about which jobs it should try to run before other jobs. Giving the same priority to all of your jobs will result in them all being treated the same. The priorities each have slightly different behaviors, as noted in their relevant javadoc. Starting in Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE:kotlin.Int`, the priority will only affect sorting order within the job's namespace. **NOTE:** 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. In order to prevent starvation, repeatedly retried jobs (because of failures) will slowly have their priorities lowered.

| Parameters ||
|---|---|
| `priority` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#PRIORITY_MIN:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#PRIORITY_LOW:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#PRIORITY_DEFAULT:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#PRIORITY_HIGH:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#PRIORITY_MAX:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#` | This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getPriority()`

### setRequiredNetwork

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setRequiredNetwork(networkRequest: NetworkRequest?): JobInfo.Builder!
```

Set detailed description of the kind of network your job requires.

If your job doesn't need a network connection, you don't need to call this method, as the default is `null`.

Calling this method defines network as a strict requirement for your job. If the network requested is not available your job will never run. See `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setOverrideDeadline(kotlin.Long)` to change this behavior. Calling this method will override any requirements previously defined by `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetworkType(kotlin.Int)`; you typically only want to call one of these methods.

When your job executes in `https://developer.android.com/reference/kotlin/android/app/job/JobService#onStartJob(android.app.job.JobParameters)`, be sure to use the specific network returned by `https://developer.android.com/reference/kotlin/android/app/job/JobParameters#getNetwork()`, otherwise you'll use the default network which may not meet this constraint. Starting in Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE:kotlin.Int`, an app must hold the `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#ACCESS_NETWORK_STATE:kotlin.String` permission to schedule a job that requires a network.

| Parameters ||
|---|---|
| `networkRequest` | [NetworkRequest](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.html#)?: The detailed description of the kind of network this job requires, or `null` if no specific kind of network is required. Defining a `https://developer.android.com/reference/kotlin/android/net/NetworkSpecifier.html#` is only supported for jobs that aren't persisted. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetworkType(kotlin.Int)`
- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getRequiredNetwork()`
- `https://developer.android.com/reference/kotlin/android/app/job/JobParameters#getNetwork()`

### setRequiredNetworkType

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setRequiredNetworkType(networkType: Int): JobInfo.Builder!
```

Set basic description of the kind of network your job requires. If you need more precise control over network capabilities, see `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetwork(android.net.NetworkRequest)`.

If your job doesn't need a network connection, you don't need to call this method, as the default value is `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_TYPE_NONE:kotlin.Int`.

Calling this method defines network as a strict requirement for your job. If the network requested is not available your job will never run. See `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setOverrideDeadline(kotlin.Long)` to change this behavior. Calling this method will override any requirements previously defined by `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetwork(android.net.NetworkRequest)`; you typically only want to call one of these methods. Starting in Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE:kotlin.Int`, an app must hold the `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#ACCESS_NETWORK_STATE:kotlin.String` permission to schedule a job that requires a network.

Starting in Android version `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE:kotlin.Int`, `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler` may try to shift the execution of jobs requiring `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_TYPE_ANY:kotlin.Int` to when there is access to an un-metered network.

When your job executes in `https://developer.android.com/reference/kotlin/android/app/job/JobService#onStartJob(android.app.job.JobParameters)`, be sure to use the specific network returned by `https://developer.android.com/reference/kotlin/android/app/job/JobParameters#getNetwork()`, otherwise you'll use the default network which may not meet this constraint.

| Parameters ||
|---|---|
| `networkType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_TYPE_NONE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_TYPE_ANY:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_TYPE_UNMETERED:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_TYPE_NOT_ROAMING:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#NETWORK_TYPE_CELLULAR:kotlin.Int` |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetwork(android.net.NetworkRequest)`
- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getNetworkType()`
- `https://developer.android.com/reference/kotlin/android/app/job/JobParameters#getNetwork()`

### setRequiresBatteryNotLow

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setRequiresBatteryNotLow(batteryNotLow: Boolean): JobInfo.Builder!
```

Specify that to run this job, the device's battery level must not be low. This defaults to false. If true, the job will only run when the battery level is not low, which is generally the point where the user is given a "low battery" warning. Setting this to `false` **DOES NOT** mean the job will only run when the battery is low.

| Parameters ||
|---|---|
| `batteryNotLow` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Whether or not the device's battery level must not be low. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isRequireBatteryNotLow()`

### setRequiresCharging

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setRequiresCharging(requiresCharging: Boolean): JobInfo.Builder!
```

Specify that to run this job, the device must be charging (or be a non-battery-powered device connected to permanent power, such as Android TV devices). This defaults to `false`. Setting this to `false` **DOES NOT** mean the job will only run when the device is not charging.

For purposes of running jobs, a battery-powered device "charging" is not quite the same as simply being connected to power. If the device is so busy that the battery is draining despite a power connection, jobs with this constraint will *not* run. This can happen during some common use cases such as video chat, particularly if the device is plugged in to USB rather than to wall power.

| Parameters ||
|---|---|
| `requiresCharging` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Pass `true` to require that the device be charging in order to run the job. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isRequireCharging()`

### setRequiresDeviceIdle

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setRequiresDeviceIdle(requiresDeviceIdle: Boolean): JobInfo.Builder!
```

When set `true`, ensure that this job will not run if the device is in active use. The default state is `false`: that is, the for the job to be runnable even when someone is interacting with the device. Setting this to `false`**DOES NOT** mean the job will only run when the device is not idle.

This state is a loose definition provided by the system. In general, it means that the device is not currently being used interactively, and has not been in use for some time. As such, it is a good time to perform resource heavy jobs. Bear in mind that battery usage will still be attributed to your application, and surfaced to the user in battery stats.

Despite the similar naming, this job constraint is *not* related to the system's "device idle" or "doze" states. This constraint only determines whether a job is allowed to run while the device is directly in use.

| Parameters ||
|---|---|
| `requiresDeviceIdle` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Pass `true` to prevent the job from running while the device is being used interactively. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isRequireDeviceIdle()`

### setRequiresStorageNotLow

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setRequiresStorageNotLow(storageNotLow: Boolean): JobInfo.Builder!
```

Specify that to run this job, the device's available storage must not be low. This defaults to false. If true, the job will only run when the device is not in a low storage state, which is generally the point where the user is given a "low storage" warning.

| Parameters ||
|---|---|
| `storageNotLow` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Whether or not the device's available storage must not be low. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isRequireStorageNotLow()`

### setTraceTag

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setTraceTag(traceTag: String?): JobInfo.Builder
```

Set a tag that will be used in `https://developer.android.com/reference/kotlin/android/os/Trace.html#`. Since this is a trace tag, it must follow the rules set in `https://developer.android.com/reference/kotlin/android/os/Trace.html#beginSection(kotlin.String)`, such as it cannot be more than 127 Unicode code units. Additionally, since leading and trailing whitespace can lead to hard-to-debug issues, they will be `https://developer.android.com/reference/kotlin/java/lang/String.html#trim()`. An empty String (after trimming) is not allowed.

| Parameters ||
|---|---|
| `traceTag` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: The tag to use in traces. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#` | This object for method chaining. This value cannot be `null`. |

### setTransientExtras

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setTransientExtras(extras: Bundle): JobInfo.Builder!
```

Set optional transient extras.

Because setting this property is not compatible with persisted jobs, doing so will throw an `https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#` when `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#build()` is called.

| Parameters ||
|---|---|
| `extras` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#): Bundle containing extras you want the scheduler to hold on to for you. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getTransientExtras()`

### setTriggerContentMaxDelay

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setTriggerContentMaxDelay(durationMs: Long): JobInfo.Builder!
```

Set the maximum total delay (in milliseconds) that is allowed from the first time a content change is detected until the job is scheduled.

| Parameters ||
|---|---|
| `durationMs` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): Delay after initial content change, in milliseconds. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getTriggerContentMaxDelay()`

### setTriggerContentUpdateDelay

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setTriggerContentUpdateDelay(durationMs: Long): JobInfo.Builder!
```

Set the delay (in milliseconds) from when a content change is detected until the job is scheduled. If there are more changes during that time, the delay will be reset to start at the time of the most recent change.

| Parameters ||
|---|---|
| `durationMs` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): Delay after most recent content change, in milliseconds. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#getTriggerContentUpdateDelay()`

### setUserInitiated

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setUserInitiated(userInitiated: Boolean): JobInfo.Builder
```

Indicates that this job is being scheduled to fulfill an explicit user request. As such, user-initiated jobs can only be scheduled when the app is in the foreground or in a state where launching an activity is allowed, as defined [here](https://developer.android.com/guide/components/activities/background-starts#exceptions). Attempting to schedule one outside of these conditions will return a `https://developer.android.com/reference/kotlin/android/app/job/JobScheduler#RESULT_FAILURE:kotlin.Int`.

This should **NOT** be used for automatic features.

All user-initiated jobs must have an associated notification, set via `https://developer.android.com/reference/kotlin/android/app/job/JobService#setNotification(android.app.job.JobParameters,%20kotlin.Int,%20android.app.Notification,%20kotlin.Int)`, and will be shown in the Task Manager when running. These jobs cannot be rescheduled by the app if the user stops the job via system provided affordance (such as the Task Manager). Thus, it is best practice and recommended to provide action buttons in the associated notification to allow the user to stop the job gracefully and allow for rescheduling.

If the app doesn't hold the `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#RUN_USER_INITIATED_JOBS:kotlin.String` permission when scheduling a user-initiated job, JobScheduler will throw a `https://developer.android.com/reference/kotlin/java/lang/SecurityException.html#`.

In `https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE:kotlin.Int`, user-initiated jobs can only be used for network data transfers. As such, they must specify a required network via `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetwork(android.net.NetworkRequest)` or `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#setRequiredNetworkType(kotlin.Int)`.

These jobs will not be subject to quotas and will be started immediately once scheduled if all constraints are met and the device system health allows for additional tasks. They are also given `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#PRIORITY_MAX:kotlin.Int` by default, and the priority cannot be changed.   
Requires `https://developer.android.com/reference/kotlin/android/Manifest.permission.html#RUN_USER_INITIATED_JOBS:kotlin.String`

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/job/JobInfo.Builder#` | This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/job/JobInfo#isUserInitiated()`