public final class BackgroundWork

  1. Object
  2. BackgroundWork
Entry point for scheduling constraint-aware background work. On Android this maps to WorkManager and on iOS to BGTaskScheduler. In the simulator the work runs on a timer and honors the constraint toggles in the Simulate menu.

Methods

public static void schedule(WorkRequest request)Schedules a unit of background work.
public static void cancel(String workId)Cancels previously scheduled work by id.
public static boolean isSupported()Returns true if the current platform supports constraint-aware background work.

Inherited methods

Method details

schedule

public static void schedule(WorkRequest request)
Schedules a unit of background work. If a request with the same id was previously scheduled it is replaced. On platforms that do not support background work this is a no-op; check #isSupported() first.

Parameters

request WorkRequest
the work request to schedule

cancel

public static void cancel(String workId)
Cancels previously scheduled work by id.

Parameters

workId String
the id of the work to cancel

isSupported

public static boolean isSupported()
Returns true if the current platform supports constraint-aware background work.

Returns

true if background work is supported