Skip to content

Instantly share code, notes, and snippets.

@aruke
Created March 10, 2019 14:30
Show Gist options
  • Save aruke/33f90e45cc627e49e75a524c82643196 to your computer and use it in GitHub Desktop.
Save aruke/33f90e45cc627e49e75a524c82643196 to your computer and use it in GitHub Desktop.
Gists to embed in WorkManager blog. Full code is available at https://github.com/aruke/WorkManagerDemo.
val workerId = simpleWorkRequest.id
WorkManager.getInstance().getWorkInfoByIdLiveData(workerId)
.observe(this, Observer<WorkInfo> {
it?.let { workInfo ->
when (workInfo.state) {
WorkInfo.State.ENQUEUED ->
Log.d(TAG, "Worker ENQUEUED")
WorkInfo.State.RUNNING ->
Log.d(TAG, "Worker RUNNING")
WorkInfo.State.SUCCEEDED ->
Log.d(TAG, "Worker SUCCEEDED")
WorkInfo.State.FAILED ->
Log.d(TAG, "Worker FAILED")
WorkInfo.State.BLOCKED ->
Log.d(TAG, "Worker BLOCKED")
WorkInfo.State.CANCELLED ->
Log.d(TAG, "Worker CANCELLED")
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment