Last active
June 25, 2022 14:26
-
-
Save ceruleanotter/300c8fd4a569f5b21921e74d14e3b35d to your computer and use it in GitHub Desktop.
WorkManager Basics: WorkStatus Observation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In your UI (activity, fragment, etc) | |
WorkManager.getInstance().getWorkInfoByIdLiveData(uploadWorkRequest.id) | |
.observe(lifecycleOwner, Observer { workInfo -> | |
// Check if the current work's state is "successfully finished" | |
if (workInfo != null && workInfo.state == WorkInfo.State.SUCCEEDED) { | |
displayImage(workInfo.outputData.getString(KEY_IMAGE_URI)) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment