Search code examples
androidandroid-workmanager

Can Android WorkManager able to run in Standby mode or App is Killed


Work manager of course can run if the phone is runing and the app is in the background.

But what if I killed the APP, or switch off the screen of the phone? What is it affect to the WorkManager?


Solution

  • Yes. That's the reason why WorkManager has been designed. Even if your device off and have a periodic work request, the system will take care of you worker once the device has been restarted. This is well tested by the Android team, no need to test it.

    However, there are 2 scenarios when the Worker doesn't get triggered:

    • Low memory, Android forces stop your app.
    • You force stop the app on your own.

    For both scenarios, in order for the WorkManager to be started you need to re-launch the closed app.

    Take a look at the docs for more: https://developer.android.com/topic/libraries/architecture/workmanager