-
Notifications
You must be signed in to change notification settings - Fork 2
Workmanager
Devrath edited this page Jun 5, 2021
·
15 revisions
Contents |
|---|
Definition |
Work manager as an assistant |
Work manager's Arsenal |
When to and when not to use work manager |
Main classes of manager |
Types of work manager requests |
-
Work-Manageris a new library fromandroid architecture components - It simplifies the work of getting the background tasks done, even if the application gets killed. This is very hard to achieve in the latest android versions using the old android
API's. - It adheres to power-saving features like doze-mode.
- It is backward compatible.
-
Work-Manageris a clever mobile assistant that helps to perform heavy tasks in the background thread. - It is in such a way that, we have certain tasks to complete, we hand over the tasks to the assistant stating the conditions in with the task has to be done. And finally, the assistant takes care of the task getting done.
- For example, You can tell the assistant work-manager to
perform a task every one hour,not to start the work until the device has network, `not to start the work until the battery is low. -
Work-managercontinues the work even if the app is in the background or the OS kills the app. - Summarizing the work-manager could intelligently use the defined factors and get the work done for you.
-
Tasks that don't need to be executed instantly need to be executed in the guarantee that is best suited for the work manager.
-
Should you need to hand over the task of performing the network request, parsing the retrieved data, and showing inactivity
->No because that can be done in an instant and can be canceled when the application process is removed. -
What about the task of sending the logs to the server, processing and syncing the data, upload a large no of videos and images, and others
->Yes because these might not have to be done instantly.
-
Should you need to hand over the task of performing the network request, parsing the retrieved data, and showing inactivity
| Classes Names | Description |
|---|---|
| WorkManager | This is the main class to enqueue the work requests |
| Worker | This is a sub-class that does the background task |
| WorkRequest | This defines the background task |
| WorkStatus | Running, Enqueued, Finished etc. |
