# Class WorkRequest.Builder

java.lang.Object
com.codename1.background.WorkRequest.Builder

Enclosing class:
  `WorkRequest`

public static final class WorkRequest.Builder extends java.lang.Object
Builder for `WorkRequest`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `WorkRequest`
  `build()`
  Builds the immutable work request.
  `WorkRequest.Builder`
  `putInputData(String key, String value)`
  Adds a key-value pair to the input data passed to the worker.
  `WorkRequest.Builder`
  `setInitialDelay(long millis)`
  Sets an initial delay before the first execution.
  `WorkRequest.Builder`
  `setPeriodic(long minIntervalMillis)`
  Makes the work periodic with the given minimum interval.
  `WorkRequest.Builder`
  `setRequiresBatteryNotLow(boolean b)`
  Requires the battery to not be low (Android only).
  `WorkRequest.Builder`
  `setRequiresCharging(boolean b)`
  Requires the device to be charging.
  `WorkRequest.Builder`
  `setRequiresIdle(boolean b)`
  Requires the device to be idle (Android only).
  `WorkRequest.Builder`
  `setRequiresNetwork(boolean b)`
  Requires any network connection.
  `WorkRequest.Builder`
  `setRequiresUnmeteredNetwork(boolean b)`
  Requires an unmetered network connection.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### setRequiresNetwork

    public WorkRequest.Builder setRequiresNetwork(boolean b)

    Requires any network connection.

    ###### Parameters

    - `b`: true to require a network

    ###### Returns

    this builder for chaining

  - ### setRequiresUnmeteredNetwork

    public WorkRequest.Builder setRequiresUnmeteredNetwork(boolean b)

    Requires an unmetered network connection.

    ###### Parameters

    - `b`: true to require an unmetered network

    ###### Returns

    this builder for chaining

  - ### setRequiresCharging

    public WorkRequest.Builder setRequiresCharging(boolean b)

    Requires the device to be charging.

    ###### Parameters

    - `b`: true to require charging

    ###### Returns

    this builder for chaining

  - ### setRequiresIdle

    public WorkRequest.Builder setRequiresIdle(boolean b)

    Requires the device to be idle (Android only).

    ###### Parameters

    - `b`: true to require device idle

    ###### Returns

    this builder for chaining

  - ### setRequiresBatteryNotLow

    public WorkRequest.Builder setRequiresBatteryNotLow(boolean b)

    Requires the battery to not be low (Android only).

    ###### Parameters

    - `b`: true to require battery-not-low

    ###### Returns

    this builder for chaining

  - ### setPeriodic

    public WorkRequest.Builder setPeriodic(long minIntervalMillis)

    Makes the work periodic with the given minimum interval. Note that platforms enforce a minimum period (for example 15 minutes on Android) and iOS only approximates periodic work by resubmission.

    ###### Parameters

    - `minIntervalMillis`: the minimum interval between executions in milliseconds

    ###### Returns

    this builder for chaining

  - ### setInitialDelay

    public WorkRequest.Builder setInitialDelay(long millis)

    Sets an initial delay before the first execution.

    ###### Parameters

    - `millis`: the delay in milliseconds

    ###### Returns

    this builder for chaining

  - ### putInputData

    public WorkRequest.Builder putInputData(String key, String value)

    Adds a key-value pair to the input data passed to the worker.

    ###### Parameters

    - `key`: the key

    - `value`: the value

    ###### Returns

    this builder for chaining

  - ### build

    public WorkRequest build()

    Builds the immutable work request.

    ###### Returns

    the work request