# PeriodicWorkRequest.Builder

Artifact: [androidx.work:work-runtime](https://developer.android.com/jetpack/androidx/releases/work) [View Source](https://cs.android.com/search?q=file:androidx/work/PeriodicWorkRequest.kt+class:androidx.work.PeriodicWorkRequest.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

*** ** * ** ***


```
public final class PeriodicWorkRequest.Builder extends WorkRequest.Builder<@NonNull PeriodicWorkRequest.Builder, @NonNull PeriodicWorkRequest>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.work.WorkRequest.Builder](https://developer.android.com/reference/androidx/work/WorkRequest.Builder)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) [PeriodicWorkRequest.Builder](https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder), @[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) [PeriodicWorkRequest](https://developer.android.com/reference/androidx/work/PeriodicWorkRequest)\> ||
|   | ↳ | [androidx.work.PeriodicWorkRequest.Builder](https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder) |

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest`s.

## Summary

| ### Public constructors |
|---|
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#Builder(java.lang.Class,java.time.Duration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html repeatInterval )` Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once every interval period. |
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#Builder(kotlin.reflect.KClass,java.time.Duration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html repeatInterval )` Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once every interval period. |
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#Builder(java.lang.Class,java.time.Duration,java.time.Duration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html repeatInterval, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html flexInterval )` Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once within the **flex period** of every interval period. |
| `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#Builder(java.lang.Class,kotlin.Long,java.util.concurrent.TimeUnit)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass, long repeatInterval, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html repeatIntervalTimeUnit )` Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once every interval period. |
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#Builder(kotlin.reflect.KClass,java.time.Duration,java.time.Duration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html repeatInterval, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html flexInterval )` Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once within the **flex period** of every interval period. |
| `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#Builder(kotlin.reflect.KClass,kotlin.Long,java.util.concurrent.TimeUnit)( @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass, long repeatInterval, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html repeatIntervalTimeUnit )` Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once every interval period. |
| `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#Builder(java.lang.Class,kotlin.Long,java.util.concurrent.TimeUnit,kotlin.Long,java.util.concurrent.TimeUnit)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass, long repeatInterval, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html repeatIntervalTimeUnit, long flexInterval, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html flexIntervalTimeUnit )` Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once within the **flex period** of every interval period. |
| `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#Builder(kotlin.reflect.KClass,kotlin.Long,java.util.concurrent.TimeUnit,kotlin.Long,java.util.concurrent.TimeUnit)( @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass, long repeatInterval, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html repeatIntervalTimeUnit, long flexInterval, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html flexIntervalTimeUnit )` Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once within the **flex period** of every interval period. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` | `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#clearNextScheduleTimeOverride()()` Clears any override set by `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#setNextScheduleTimeOverride(kotlin.Long)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` | `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#setNextScheduleTimeOverride(kotlin.Long)(long nextScheduleTimeOverrideMillis)` Overrides the next time this work is scheduled to run. |

### Inherited methods

From [androidx.work.WorkRequest.Builder](https://developer.android.com/reference/androidx/work/WorkRequest.Builder) `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#addTag(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html tag)`

Adds a tag for the work.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#build()()`

Builds a `https://developer.android.com/reference/androidx/work/WorkRequest` based on this `https://developer.android.com/reference/androidx/work/WorkRequest.Builder`.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26)
https://developer.android.com/reference/androidx/work/WorkRequest.Builder#keepResultsForAtLeast(java.time.Duration)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html duration)`

Specifies that the results of this work should be kept for at least the specified amount of time.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#keepResultsForAtLeast(kotlin.Long,java.util.concurrent.TimeUnit)(long duration, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html timeUnit)`

Specifies that the results of this work should be kept for at least the specified amount of time.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26)
https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setBackoffCriteria(androidx.work.BackoffPolicy,java.time.Duration)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/BackoffPolicy backoffPolicy,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html duration
)`

Sets the backoff policy and backoff delay for the work.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setBackoffCriteria(androidx.work.BackoffPolicy,kotlin.Long,java.util.concurrent.TimeUnit)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/BackoffPolicy backoffPolicy,
long backoffDelay,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html timeUnit
)`

Sets the backoff policy and backoff delay for the work.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `@https://developer.android.com/reference/androidx/work/ExperimentalWorkRequestBuilderApi
https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setBackoffForSystemInterruptions()()`

Specifies that the backoff policy (as specified via `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setBackoffCriteria(androidx.work.BackoffPolicy,kotlin.Long,java.util.concurrent.TimeUnit)`) will be applied when work is interrupted by the system without the app requesting it.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setConstraints(androidx.work.Constraints)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Constraints constraints)`

Adds constraints to the `https://developer.android.com/reference/androidx/work/WorkRequest`.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setExpedited(androidx.work.OutOfQuotaPolicy)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/OutOfQuotaPolicy policy)`

Marks the `https://developer.android.com/reference/androidx/work/WorkRequest` as important to the user.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setId(java.util.UUID)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/UUID.html id)`

Sets a unique identifier for this unit of work.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26)
https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setInitialDelay(java.time.Duration)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html duration)`

Sets an initial delay for the `https://developer.android.com/reference/androidx/work/WorkRequest`.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setInitialDelay(kotlin.Long,java.util.concurrent.TimeUnit)(long duration, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html timeUnit)`

Sets an initial delay for the `https://developer.android.com/reference/androidx/work/WorkRequest`.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setInputData(androidx.work.Data)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Data inputData)`

Adds input `https://developer.android.com/reference/androidx/work/Data` to the work.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder` `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#setTraceTag(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html traceTag)`

Specifies the name of the trace span to be used by `https://developer.android.com/reference/androidx/work/WorkManager` when executing the specified `https://developer.android.com/reference/androidx/work/WorkRequest`.

## Public constructors

### Builder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
@RequiresApi(value = 26)
public Builder(
    @NonNull Class<@NonNull ListenableWorker> workerClass,
    @NonNull Duration repeatInterval
)
```

Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once every interval period. The `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` is guaranteed to run exactly one time during this interval (subject to OS battery optimizations, such as doze mode). The repeat interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS()`. It may run immediately, at the end of the period, or any time in between so long as the other conditions are satisfied at the time. The run time of the `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` can be restricted to a flex period within an interval (see `#Builder(Class, Duration, Duration)`).

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass` | The `https://developer.android.com/reference/androidx/work/ListenableWorker` class to run for this work |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html repeatInterval` | The repeat interval |

### Builder

Added in [2.10.0](https://developer.android.com/jetpack/androidx/releases/work#2.10.0)

```
@RequiresApi(value = 26)
public Builder(
    @NonNull KClass<@NonNull ListenableWorker> workerClass,
    @NonNull Duration repeatInterval
)
```

Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once every interval period. The `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` is guaranteed to run exactly one time during this interval (subject to OS battery optimizations, such as doze mode). The repeat interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS()`. It may run immediately, at the end of the period, or any time in between so long as the other conditions are satisfied at the time. The run time of the `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` can be restricted to a flex period within an interval (see `#Builder(Class, Duration, Duration)`).

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass` | The `https://developer.android.com/reference/androidx/work/ListenableWorker` class to run for this work |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html repeatInterval` | The repeat interval |

### Builder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
@RequiresApi(value = 26)
public Builder(
    @NonNull Class<ListenableWorker> workerClass,
    @NonNull Duration repeatInterval,
    @NonNull Duration flexInterval
)
```

Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once within the **flex period** of every interval period. See diagram below. The flex period begins at `repeatInterval - flexInterval` to the end of the interval. The repeat interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS()` and the flex interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_FLEX_MILLIS()`.

```
[_____before flex_____|_____flex_____][_____before flex_____|_____flex_____]...
[___cannot run work___|_can run work_][___cannot run work___|_can run work_]...
\____________________________________/\____________________________________/...
interval 1                            interval 2             ...(repeat)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass` | The `https://developer.android.com/reference/androidx/work/ListenableWorker` class to run for this work |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html repeatInterval` | The repeat interval |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html flexInterval` | The duration in for which this work repeats from the end of the `repeatInterval` |

### Builder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public Builder(
    @NonNull Class<ListenableWorker> workerClass,
    long repeatInterval,
    @NonNull TimeUnit repeatIntervalTimeUnit
)
```

Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once every interval period. The `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` is guaranteed to run exactly one time during this interval (subject to OS battery optimizations, such as doze mode). The repeat interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS()`. It may run immediately, at the end of the period, or any time in between so long as the other conditions are satisfied at the time. The run time of the `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` can be restricted to a flex period within an interval (see `#Builder(Class, long, TimeUnit, long, TimeUnit)`).

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass` | The `https://developer.android.com/reference/androidx/work/ListenableWorker` class to run for this work |
| `long repeatInterval` | The repeat interval in `repeatIntervalTimeUnit` units |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html repeatIntervalTimeUnit` | The `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html` for `repeatInterval` |

### Builder

Added in [2.10.0](https://developer.android.com/jetpack/androidx/releases/work#2.10.0)

```
@RequiresApi(value = 26)
public Builder(
    @NonNull KClass<@NonNull ListenableWorker> workerClass,
    @NonNull Duration repeatInterval,
    @NonNull Duration flexInterval
)
```

Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once within the **flex period** of every interval period. See diagram below. The flex period begins at `repeatInterval - flexInterval` to the end of the interval. The repeat interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS()` and the flex interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_FLEX_MILLIS()`.

```
[_____before flex_____|_____flex_____][_____before flex_____|_____flex_____]...
[___cannot run work___|_can run work_][___cannot run work___|_can run work_]...
\____________________________________/\____________________________________/...
interval 1                            interval 2             ...(repeat)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass` | The `https://developer.android.com/reference/androidx/work/ListenableWorker` class to run for this work |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html repeatInterval` | The repeat interval |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Duration.html flexInterval` | The duration in for which this work repeats from the end of the `repeatInterval` |

### Builder

Added in [2.10.0](https://developer.android.com/jetpack/androidx/releases/work#2.10.0)

```
public Builder(
    @NonNull KClass<@NonNull ListenableWorker> workerClass,
    long repeatInterval,
    @NonNull TimeUnit repeatIntervalTimeUnit
)
```

Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once every interval period. The `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` is guaranteed to run exactly one time during this interval (subject to OS battery optimizations, such as doze mode). The repeat interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS()`. It may run immediately, at the end of the period, or any time in between so long as the other conditions are satisfied at the time. The run time of the `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` can be restricted to a flex period within an interval (see `#Builder(Class, long, TimeUnit, long, TimeUnit)`).

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass` | The `https://developer.android.com/reference/androidx/work/ListenableWorker` class to run for this work |
| `long repeatInterval` | The repeat interval in `repeatIntervalTimeUnit` units |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html repeatIntervalTimeUnit` | The `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html` for `repeatInterval` |

### Builder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public Builder(
    @NonNull Class<ListenableWorker> workerClass,
    long repeatInterval,
    @NonNull TimeUnit repeatIntervalTimeUnit,
    long flexInterval,
    @NonNull TimeUnit flexIntervalTimeUnit
)
```

Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once within the **flex period** of every interval period. See diagram below. The flex period begins at `repeatInterval - flexInterval` to the end of the interval. The repeat interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS()` and the flex interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_FLEX_MILLIS()`.

```
[_____before flex_____|_____flex_____][_____before flex_____|_____flex_____]...
[___cannot run work___|_can run work_][___cannot run work___|_can run work_]...
\____________________________________/\____________________________________/...
interval 1                            interval 2             ...(repeat)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass` | The `https://developer.android.com/reference/androidx/work/ListenableWorker` class to run for this work |
| `long repeatInterval` | The repeat interval in `repeatIntervalTimeUnit` units |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html repeatIntervalTimeUnit` | The `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html` for `repeatInterval` |
| `long flexInterval` | The duration in `flexIntervalTimeUnit` units for which this work repeats from the end of the `repeatInterval` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html flexIntervalTimeUnit` | The `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html` for `flexInterval` |

### Builder

Added in [2.10.0](https://developer.android.com/jetpack/androidx/releases/work#2.10.0)

```
public Builder(
    @NonNull KClass<@NonNull ListenableWorker> workerClass,
    long repeatInterval,
    @NonNull TimeUnit repeatIntervalTimeUnit,
    long flexInterval,
    @NonNull TimeUnit flexIntervalTimeUnit
)
```

Creates a `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest` to run periodically once within the **flex period** of every interval period. See diagram below. The flex period begins at `repeatInterval - flexInterval` to the end of the interval. The repeat interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS()` and the flex interval must be greater than or equal to `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_FLEX_MILLIS()`.

```
[_____before flex_____|_____flex_____][_____before flex_____|_____flex_____]...
[___cannot run work___|_can run work_][___cannot run work___|_can run work_]...
\____________________________________/\____________________________________/...
interval 1                            interval 2             ...(repeat)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ListenableWorker> workerClass` | The `https://developer.android.com/reference/androidx/work/ListenableWorker` class to run for this work |
| `long repeatInterval` | The repeat interval in `repeatIntervalTimeUnit` units |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html repeatIntervalTimeUnit` | The `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html` for `repeatInterval` |
| `long flexInterval` | The duration in `flexIntervalTimeUnit` units for which this work repeats from the end of the `repeatInterval` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/TimeUnit.html flexIntervalTimeUnit` | The `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html` for `flexInterval` |

## Public methods

### clearNextScheduleTimeOverride

Added in [2.9.0](https://developer.android.com/jetpack/androidx/releases/work#2.9.0)

```
public final @NonNull PeriodicWorkRequest.Builder clearNextScheduleTimeOverride()
```

Clears any override set by `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#setNextScheduleTimeOverride(kotlin.Long)`.

When an override is cleared, the next schedule is based on the previous enqueue time or run time of the Work and the result of that previous run. Eg. if the previous run returned `https://developer.android.com/reference/androidx/work/ListenableWorker.Result.Retry` at some time=T, and the next run was set by override, then clearing that override will return the schedule to `T+backoffInterval` if using linear backoff.

Override may be cleared while a Worker is running. The worker will schedule the next run based on its result type and interval.

### setNextScheduleTimeOverride

Added in [2.9.0](https://developer.android.com/jetpack/androidx/releases/work#2.9.0)

```
public final @NonNull PeriodicWorkRequest.Builder setNextScheduleTimeOverride(long nextScheduleTimeOverrideMillis)
```

Overrides the next time this work is scheduled to run.

Calling this method sets a specific time at which the work will be scheduled to run next, overriding the normal interval, flex, initial delay, and backoff.

This allows dynamic calculation of the next Periodic work schedule, which can be used to implement advanced features like adaptive refresh times, custom retry behavior, or making a newsfeed worker run before the user wakes up every morning without drift. `https://developer.android.com/reference/androidx/work/ExistingPeriodicWorkPolicy#UPDATE` should be used with these techniques to avoid cancelling a currently-running worker while scheduling the next one.

This method only sets the single next Work schedule. After that Work finishes, the override will be cleared and the Work will be scheduled normally according to the interval or backoff. The override can be cleared by setting `https://developer.android.com/reference/androidx/work/PeriodicWorkRequest.Builder#clearNextScheduleTimeOverride()` on a work update request. Otherwise, the override time will persist after unrelated invocations of `https://developer.android.com/reference/androidx/work/WorkManager#updateWork(androidx.work.WorkRequest)`.

This method can be used from outside or inside a `https://developer.android.com/reference/androidx/work/Worker#startWork()` method. If the Worker is currently running, then it will override the next time the Work starts, even if the current Worker returns `https://developer.android.com/reference/androidx/work/ListenableWorker.Result.Retry`. This behavior can be used to customize the backoff behavior of a Worker by catching Exceptions in startWork and using this method to schedule a retry.

`https://developer.android.com/reference/androidx/work/PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS()` is enforced on this method to prevent infinite loops. If a previous run time occurred less than the minimum period before the override time, then the override schedule will be delayed to preserve the minimum spacing. This restriction does not apply to the very first run of periodic work, which may be instant.

Work will almost never run at this exact time in the real world. This method assigns the scheduled run time accurately, but cannot guarantee an actual run time. Actual Work run times are dependent on many factors like the underlying system scheduler, doze and power saving modes of the OS, and meeting any configured constraints. This is expected and is not considered a bug.

| Parameters |
|---|---|
| `long nextScheduleTimeOverrideMillis` | The time, in `https://developer.android.com/reference/java/lang/System.html#currentTimeMillis()` time, to schedule this work next. If this is in the past, work may run immediately. |