Group Group Group Group Group Group Group Group Group

Jetpack WorkManager: Getting Started | raywenderlich.com


#1

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9161-jetpack-workmanager-getting-started

#2

This is so amazing. A really great screencast. More of a real world case. I am so happy to see such content from you guys. Keep up the good work. Thanks


#3

How to run an async code inside doWork()? I mean if I am doing a login network call(using retrofit) inside the doWork() method and I want to pass the result from the network call back to the Activity till that time I want to show a ProgressBar. Once I get the result I will navigate user to next screen. How can I achieve this?


#4

Hi @sagarsuri, thanks for the question!

We have a second WorkManager screencast coming out in the next week or so that shows you how to observe WorkStatus using LiveData. In the screencast, we use that to show a ProgressBar while the zip file is uploading. The second screencast also talks about unique work, canceling work, and work constraints. Look for that screencast next week.

Having said that, be sure to think about your login use case and remember that WorkManager is used for guaranteed but deferrable work, like the file upload in our screencast. Many network requests you would make with Retrofit are not considered deferrable, so a different async approach such as RxJava may be better.

Thanks again!