Ultimate magazine theme for WordPress.

Android Jetpack: Introducing WorkManager


The Android WorkManager library makes it easy to schedule deferrable tasks that are expected to run even if the app exits or the device restarts. Need to sync photos with a server, or do a daily cache clean-up? Then WorkManager is the library for you! Because WorkManager is compatible with API 14+ and follows system health best practices, it is the recommended approach for handling most background execution tasks on Android.

WorkManager supports:
-One-off and periodic tasks
-Constraints, such as network availability
-Chaining tasks, parallel or sequentially
-Observable task state for display in UI
-Customized threading strategy

To learn more about WorkManager, check out:

The WorkManager Documentation →

WorkManager Codelab: Kotlin → and Java →

Working with WorkManager Presentation at Android Dev Summit 18′ →

Google Power Blogpost Series →

Introducing WorkManager Blogpost →

WorkManager Basics Blogpost →

LiveData Overview Documentation → (for understanding getWorkInfosByTagLiveData →

Reference Documentation →

Source code (part of AOSP) →

Issue Tracker →

Watch more Android Jetpack videos here →

Subscribe to the Android Developers channel here →


Source: https://blogema.org
Read more all post Android Technology : https://blogema.org/android/
  1. Pratik Shinde says

    I was asked about this in interview yesterday.. pulled it off like a boss ? thank you for jetpack

  2. Michael Mathias says

    I am trying to handle push notification on a chat app I am creating and I am using FCM. While the app is running, I use web socket to connect the client app to the server, but once the app is killed, I want to use FCM to send push notification when a user have new messages just like whatsapp, twitter, instagram, facebook, gmail and other popular apps do. The problem is that using FCM only shows the notification while the app is in the foreground of in the background, but when the app is not running or swiped out from recent task menu, no notification is received anymore. I have set the priority of the notification sent from the server as high but still nothing. Please if can let me know what I am doing wrong I would really appreciate.

  3. Faisal Shaikh says

    WorkManager does not complete the work when app is killed by swiping. Can you please explain how to complete the work when app is killed.

  4. Adityakumar Yadav says

    can workmanager be used for step counter to count steps when app is killed or system is sleeping/suspend mode ? Plz response me asap

  5. n o i d says

    I have the following scenario:

    My production app has a recurring sync job which runs daily (based on Firebase JobDispatcher).
    I migrated from JobDispatcher to WorkManager (following the official migration guide from Google).
    After I installed the new apk on top of the old one, the old recurring schedule is lost (as expected), so once the app is automatically updated from the Play Store to the new apk, the user actually has to know to open my app manually, in order to trigger the rescheduling with the WorkManager implementation.

    Once I open the updated app, it knows that the app was updated because I check if the old version code (saved in shared prefs) is lower than the current one, and it reschedules the periodic task with WorkManager, and everything works fine afterwards.

    This wasn't covered in the migration guide but I don't think it's an uncommon case. Do you have any ideas how to gracefully handle this?

    Later edit: I managed to do it by keeping the old service class (same class name, same package) but when the service is started, I just reschedule using WorkManager and then I cancel the old JobService forever. This way, the user doesn't have to open the app after the update.

  6. govind marathe says

    How does workmanager will work even if app is closed?????? will it work??? from background without running app????????? will it sendthe data to server???????

  7. MELA TECH says

    It was an important video… I've learnt a lot from it, is the cross you are wearing from Ethiopia

  8. Zintom v1 says

    Work, work, work, work.

  9. Randy Lutcavich says

    Can you explain 4:14?

    "Now by default, worker does work off of the main thread using an executor behind the scenes."

    But the slide says:
    "doWork() called on background thread by Executor"

    What kind of work is WorkManager doing on the main thread if the executor is running on a background thread?
    What's the disadvantages to it being on the main thread?

  10. Сергей Ситько says

    It's not validate code. It wont work Bla bla bla… We google we don't make mistakes in a presentation… Fun)… In Worker we must pass Context which is "c" parameter not ctx….

  11. Htop Skills says

    Why I do see new example in Java?

  12. Liran Barsisa says

    Was Firebase removed from gradle as optional dependency that WorkManager can use? I don't see it on the docs anymore…
    Also, it seems many classes were changed over time or removed. What should I do if I want to migrate from 1.0.0-alpha09 ?

  13. TheNylon100 says

    JAVA <3

  14. Ольга Куликова says

    Hello. I am looking for a google play console with live game applications (the older the better). Who is ready to sell along with the source (developer key, application project)? Conditions in private messages

  15. Abhishek Sengupta says

    Why every examples are in Kotlin ? Please add Java also :[

  16. Aminlv says

    seems quiet useful tnX

  17. Nicolai Weitkemper says

    Cool, but why does Google Play Store use >20% of my battery then? ?

  18. Prime. Prime says

    wish this video was available before. I searched internet a lot for using work manager.

  19. Cen Cuz says

    Sounds great ! hope that can really solve the problem you mentioned.

  20. Md. Moontasirul Islam says

    Is it possible the periodic Task time interval 15 seconds in workManager.?
    I found workManager periodic task minimum time interval is 15 minutes. 🙁

  21. guruprasad yallapu says

    For the God sake !

    Why do we need to connect to network or charging (Constrains) to upload photos !. The work will be cancelled if disconnects from network and later retry once connects !?. Why the work should be deferrable in this case .

    Even noticed the same in job schedulers !!!!! . If you don't set constrains in JobSchedulers ,I will be run time error . But in workmanger the work will be executed right away if no constrains right !?.

  22. sauloegito2 says

    Good stuff but getWorkInfoIdByLiveData sounds like an anti-pattern method, if I'd review the PR I'd suggest getWorkStateById instead. As users of the API we are requesting a state and for us it doesn't matter if Google uses LiveData behind the rug, if the method returns an Observable we already know enough, there's no need to add LiveData suffix on this method.

  23. Shehan Abid says

    This will solve
    java.lang.IllegalStateException: Not allowed to start service Intent app is in background Error

  24. Go Fudge YourSelves says

    Is there a possibility of Work Manager running when the app is in the foreground and meets all the constraints specified???

  25. Go Fudge YourSelves says

    Create a WorkManager Plugin for Flutter

  26. eatthepi says

    This library serves an important need. We used evernote/android-job to do this in past projects — this library does almost exactly the same thing. Even when workManager was in alpha it was stable (as in it didn't crash) but they were still playing with the API.

  27. Hayk Mkrtchyan says

    Question to everyone. You have a chat application that works with sockets. Steps you have to do in background. You create socket, connect it, then you create a channel and listen to this channel. When someone writes you message, channel says you have a new message from x user. After this you have to show notification and say server (send event) that you got the message. Here is it. Question to everyone. How you can realize this work in background without limitations?

  28. Nour Ahmed says

    what is the best way to get notification on sql server changes?

  29. Norman Sánchez says

    I love Android ?

  30. DZ NEEDS CODE says

    I've always believed that the android is awesome

  31. baturay Alhaj Ahmad says

    is there a codelab for workmanager ?

  32. Filippo Engidashet says

    Good talk – btw where did you find out the cross you're wearing?

  33. nisetsu says

    Google is finally figuring out why Windows had a task scheduler for the last 20 years. Give it 10 more years and Google might figure out why Windows hardware drivers are independent of OS updates.

  34. Shahab Azimi says

    for god's sakes use JAVA

  35. CopernicoTube says

    Finally we don't need to code endless boilerplates trying to combine Receivers and Job Scheduler anymore… Yay!

  36. Robert Chrzanowski says

    Nice work. Love composable api for building chains of work. FP FTW!

  37. Bartek Wojak says

    That's exactly what I've been looking for the last days! Thanks!

  38. Coding in Flow says

    It's still in beta right? I will create a tutorial on it once it's stable.

  39. Pavel Sumin says

    Thx for your work guys!

  40. oyze says

    @1:21 sounds virusy

  41. Happy donkey says


  42. Rishabh Rawat says

    I already use the Workmanager for my production app but I noticed in Workmanager API that some Chinese ROM (MiUi, EMUI) are not able to perform a periodic work. I don't know, is this bug or some optimization in ROM but at same time stock android perform very well to perform the periodic task.

  43. Mohammad Kashif Khan says

    So, will the job scheduler get deprecated in future and this will be the way to go?

  44. Amarpreet Singh says

    Work manger useful for alarm?

  45. rai AN says

    that is cool..!! thx @CeruleanOtter

  46. Abdul says

    huh, doesn't sound like my WorkManager! He's neither deferrable, nor guaranteed!

  47. Mudassir Zulfiqar says

    How to get current location even in doze mode with WM

  48. Segura Mlk says

    Cool. Ease of use. That's what devs want

  49. ALI HAIDER says


Leave A Reply

Your email address will not be published.