Builder

class Builder : WorkRequest.Builder<PeriodicWorkRequest.Builder!, PeriodicWorkRequest!>
kotlin.Any
   ↳ androidx.work.WorkRequest.Builder<androidx.work.PeriodicWorkRequest.Builder, androidx.work.PeriodicWorkRequest>
   ↳ androidx.work.PeriodicWorkRequest.Builder

Builder for PeriodicWorkRequests.

Summary

Public constructors

<init>(@NonNull workerClass: Class<out ListenableWorker!>, repeatInterval: Long, @NonNull repeatIntervalTimeUnit: TimeUnit)

Creates a PeriodicWorkRequest to run periodically once every interval period.

<init>(@NonNull workerClass: Class<out ListenableWorker!>, @NonNull repeatInterval: Duration)

Creates a PeriodicWorkRequest to run periodically once every interval period.

<init>(@NonNull workerClass: Class<out ListenableWorker!>, repeatInterval: Long, @NonNull repeatIntervalTimeUnit: TimeUnit, flexInterval: Long, @NonNull flexIntervalTimeUnit: TimeUnit)

Creates a PeriodicWorkRequest to run periodically once within the flex period of every interval period.

<init>(@NonNull workerClass: Class<out ListenableWorker!>, @NonNull repeatInterval: Duration, @NonNull flexInterval: Duration)

Creates a PeriodicWorkRequest to run periodically once within the flex period of every interval period.

Inherited functions

Public constructors

<init>

Builder(@NonNull workerClass: Class<out ListenableWorker!>, repeatInterval: Long, @NonNull repeatIntervalTimeUnit: TimeUnit)

Creates a PeriodicWorkRequest to run periodically once every interval period. The 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 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 PeriodicWorkRequest can be restricted to a flex period within an interval (see Builder(Class, long, TimeUnit, long, TimeUnit)).

Parameters
workerClass Class<out ListenableWorker!>: The ListenableWorker class to run for this work
repeatInterval Class<out ListenableWorker!>: The repeat interval in repeatIntervalTimeUnit units
repeatIntervalTimeUnit Class<out ListenableWorker!>: The TimeUnit for repeatInterval

<init>

Builder(@NonNull workerClass: Class<out ListenableWorker!>, @NonNull repeatInterval: Duration)

Creates a PeriodicWorkRequest to run periodically once every interval period. The 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 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 PeriodicWorkRequest can be restricted to a flex period within an interval (see Builder(Class, Duration, Duration)).

Parameters
workerClass Class<out ListenableWorker!>: The ListenableWorker class to run for this work
repeatInterval Class<out ListenableWorker!>: The repeat interval

<init>

Builder(@NonNull workerClass: Class<out ListenableWorker!>, repeatInterval: Long, @NonNull repeatIntervalTimeUnit: TimeUnit, flexInterval: Long, @NonNull flexIntervalTimeUnit: TimeUnit)

Creates a PeriodicWorkRequest to run periodically once within the flex period of every interval period. See diagram below. Note that flex intervals are ignored for certain OS versions (in particular, API 23). The flex period begins at repeatInterval - flexInterval to the end of the interval. The repeat interval must be greater than or equal to PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS and the flex interval must be greater than or equal to 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
workerClass Class<out ListenableWorker!>: The ListenableWorker class to run for this work
repeatInterval Class<out ListenableWorker!>: The repeat interval in repeatIntervalTimeUnit units
repeatIntervalTimeUnit Class<out ListenableWorker!>: The TimeUnit for repeatInterval
flexInterval Class<out ListenableWorker!>: The duration in flexIntervalTimeUnit units for which this work repeats from the end of the repeatInterval
flexIntervalTimeUnit Class<out ListenableWorker!>: The TimeUnit for flexInterval

<init>

Builder(@NonNull workerClass: Class<out ListenableWorker!>, @NonNull repeatInterval: Duration, @NonNull flexInterval: Duration)

Creates a PeriodicWorkRequest to run periodically once within the flex period of every interval period. See diagram below. Note that flex intervals are ignored for certain OS versions (in particular, API 23). The flex period begins at repeatInterval - flexInterval to the end of the interval. The repeat interval must be greater than or equal to PeriodicWorkRequest#MIN_PERIODIC_INTERVAL_MILLIS and the flex interval must be greater than or equal to 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
workerClass Class<out ListenableWorker!>: The ListenableWorker class to run for this work
repeatInterval Class<out ListenableWorker!>: The repeat interval
flexInterval Class<out ListenableWorker!>: The duration in for which this work repeats from the end of the repeatInterval