Search code examples
androidandroid-workmanager

Can an Android Worker run without calling Application.onCreate?


I'm scheduling a unique Periodic work which I'm guessing at some point will run even when my app is not running, not even in the background.

My question is, when my app is completely terminated and my worker gets launched by the OS, will my Application.onCreate method be called before my worker runs? Or will it run completely isolated from the app?

There are some dependencies initialized in my Application.onCreate method that are needed for my worker to run, so if my worker can run in complete isolation, then I'll have to set those up inside the worker itself. Though I'm not sure that's the case.


Solution

  • It will run your App. Don't worry. All event's like this will run your App and onCreate(). It applies to Manifest Broadcast receivers, AlarmManager timers, etc.