PeriodicWorkRequest.Builder
public
static
final
class
PeriodicWorkRequest.Builder
extends Builder<PeriodicWorkRequest.Builder, PeriodicWorkRequest>
java.lang.Object | ||
↳ | androidx.work.WorkRequest.Builder<androidx.work.PeriodicWorkRequest.Builder, androidx.work.PeriodicWorkRequest> | |
↳ | androidx.work.PeriodicWorkRequest.Builder |
Builder for PeriodicWorkRequest
s.
Summary
Public constructors | |
---|---|
Builder(Class<? extends ListenableWorker> workerClass, long repeatInterval, TimeUnit repeatIntervalTimeUnit)
Creates a |
|
Builder(Class<? extends ListenableWorker> workerClass, Duration repeatInterval)
Creates a |
|
Builder(Class<? extends ListenableWorker> workerClass, long repeatInterval, TimeUnit repeatIntervalTimeUnit, long flexInterval, TimeUnit flexIntervalTimeUnit)
Creates a |
|
Builder(Class<? extends ListenableWorker> workerClass, Duration repeatInterval, Duration flexInterval)
Creates a |
Inherited methods | |
---|---|
Public constructors
Builder
public Builder (Class<? extends ListenableWorker> workerClass, long repeatInterval, TimeUnit repeatIntervalTimeUnit)
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 : The ListenableWorker class to run for this work |
repeatInterval |
long : The repeat interval in repeatIntervalTimeUnit units |
repeatIntervalTimeUnit |
TimeUnit : The TimeUnit for repeatInterval
|
Builder
public Builder (Class<? extends ListenableWorker> workerClass, Duration repeatInterval)
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 : The ListenableWorker class to run for this work |
repeatInterval |
Duration : The repeat interval
|
Builder
public Builder (Class<? extends ListenableWorker> workerClass, long repeatInterval, TimeUnit repeatIntervalTimeUnit, long flexInterval, TimeUnit flexIntervalTimeUnit)
Creates a 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
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 : The ListenableWorker class to run for this work |
repeatInterval |
long : The repeat interval in repeatIntervalTimeUnit units |
repeatIntervalTimeUnit |
TimeUnit : The TimeUnit for repeatInterval |
flexInterval |
long : The duration in flexIntervalTimeUnit units for which this
work repeats from the end of the repeatInterval |
flexIntervalTimeUnit |
TimeUnit : The TimeUnit for flexInterval
|
Builder
public Builder (Class<? extends ListenableWorker> workerClass, Duration repeatInterval, Duration flexInterval)
Creates a 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
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 : The ListenableWorker class to run for this work |
repeatInterval |
Duration : The repeat interval |
flexInterval |
Duration : The duration in for which this work repeats from the end of the
repeatInterval
|