KmpTaskWorker

WorkManager CoroutineWorker that bridges the Android scheduling system into the KMPWorker execution model.

Lifecycle per execution:

  1. Reads taskId + retry policy from inputData

  2. Checks if max retries exhausted — returns Result.failure if so

  3. Emits TaskState.Running()

  4. Builds TaskExecutionContext with taskId, retryCount, payload, tags

  5. Invokes registered handler via TaskRegistry.execute

  6. Success → emits TaskState.Success → returns Result.success

  7. Failure → checks retry policy → Result.retry or Result.failure

Constructors

Link copied to clipboard
constructor(context: Context, params: WorkerParameters)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val coroutineContext: CoroutineDispatcher

Functions

Link copied to clipboard
open suspend override fun doWork(): ListenableWorker.Result
Link copied to clipboard
open suspend fun getForegroundInfo(): ForegroundInfo
Link copied to clipboard
override fun getForegroundInfoAsync(): ListenableFuture<ForegroundInfo>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@RequiresApi(value = 31)
fun getStopReason(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
override fun onStopped()
Link copied to clipboard
suspend fun setForeground(foregroundInfo: ForegroundInfo)
Link copied to clipboard
fun setForegroundAsync(@NonNull foregroundInfo: ForegroundInfo): ListenableFuture<Void>
Link copied to clipboard
suspend fun setProgress(data: Data)
Link copied to clipboard
open fun setProgressAsync(@NonNull data: Data): ListenableFuture<Void>
Link copied to clipboard
Link copied to clipboard
override fun startWork(): ListenableFuture<ListenableWorker.Result>
Link copied to clipboard