Skip to content

Instantly share code, notes, and snippets.

@adriantache
Last active October 20, 2018 10:26
Show Gist options
  • Save adriantache/871403b423bd7d6e380fbda4bad0e3c1 to your computer and use it in GitHub Desktop.
Save adriantache/871403b423bd7d6e380fbda4bad0e3c1 to your computer and use it in GitHub Desktop.
//WARNING: this code is no longer valid as of WorkManager-alpha-10, please
//refer to this post for more details: https://medium.com/p/8e49c463cbf7
//finally, we get the status from the WorkManager by id since we still have
//a reference, otherwise we could do it by tag, and create an observer which
//checks whether the Worker has succeeded (i.e. returned Worker.Result.SUCCESS)
WorkManager.getInstance()
.getStatusById(getEventJson.getId())
.observe(MainActivity.this, workStatus -> {
if (workStatus != null && workStatus.getState().equals(State.SUCCEEDED)) {
//if we have success, we trigger post-work tasks
onWorkCompleted();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment