Background work
Each and every Android application deals with data and processing that data is one of the most important part. Generally, we should take any blocking tasks off the UI thread. The long-running tasks like decoding a bitmap, accessing storage, working on a ML (Machine Learning) model or network requests all these tasks should be moved off the UI thread to the Background Thread. An app is running in the background when none of the app’s activities are currently visible to the user and the app isn’t running any foreground services that started while an activity from the app was visible to the user.
Types of Background work
Background work are categorised primarily into three categories :-
- Immediate : Tasks that needs to execute right away and complete asap.
- Long Running : Tasks that may take some time to complete
- Deferrable : Tasks that does not need to run right away
Likewise, Work is also categories into two categories,
- Persistent work : Work that remains scheduled even if the app restarts and device reboots.
- Impersistent work : Work that does not remain scheduled after the process ends.