# Interface BackgroundWorker

public interface BackgroundWorker

Implemented by an application class to perform constraint-aware background work scheduled through `BackgroundWork#schedule(WorkRequest)`.

The implementing class MUST have a public no-argument constructor: the platform may reconstruct a fresh instance after the app process has been killed and cold launched to run the work, so no state from the foreground app is available. Pass any required state through the work request input data.

##### See also

- BackgroundWork

- WorkRequest

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `performWork(String workId, Map<String,String> inputData, long deadline, Callback<Boolean> onComplete)`
  Performs the background work.

- ## Method Details

  - ### performWork

    void performWork(String workId, Map<String,String> inputData, long deadline, Callback<Boolean> onComplete)

    Performs the background work. The implementation should call `onComplete` with `Boolean.TRUE` on success or `Boolean.FALSE` to request that the platform retry the work later. The work must finish before `deadline`; if it does not, the platform may terminate it.

    ###### Parameters

    - `workId`: the id of the work request being executed

    - `inputData`: the immutable input data supplied to the work request

    - `deadline`: the time in milliseconds since the epoch by which the work must finish

    - `onComplete`: callback invoked with the outcome (true for success, false to retry)