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


  1. 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.

  2. 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.

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

  4. 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.

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

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

  7. 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?

  8. 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….

  9. 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 ?

  10. 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

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

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

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

  14. 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 !?.

  15. 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.

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

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

  18. 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.

  19. 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?

  20. 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.

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

  22. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *