run

fun run(mode: BackgroundMode, task: BackgroundTask? = null, taskKey: String? = null)(source)

Runs task (or the pre-registered worker at taskKey) using the given mode.

Parameters

mode

Which background strategy to use — see BackgroundMode.

task

Inline task for BackgroundMode.Coroutine (ignored for other modes).

taskKey

Key of a pre-registered worker for WorkManager / Foreground modes. Defaults to the BackgroundMode.WorkManagerOnce.uniqueName or BackgroundMode.WorkManagerPeriodic.uniqueName when applicable.