Search code examples
androidmultithreadingbackground-task

Difference between Deferred and Exact background tasks


I was reading Guide To Background Tasks, it's well organized and understandable except a few concepts. Can anyone differentiate between Deferred and Exact background Tasks with some realtime android examples?


Solution

  • Deferred tasks Every task that is not directly connected to a user interaction and can run at any time in the future can be deferred. The recommended solution for deferred tasks is WorkManager.

    WorkManager makes it easy to schedule deferrable, asynchronous tasks that are expected to run even if the app exits or the device restarts. See the documentation for WorkManager to learn how to schedule these types of tasks.

    Exact tasks A task that needs to be executed at an exact point in time can use AlarmManager.

    To learn more about AlarmManager, see Schedule repeating alarms.