Android applications should use background tasks when appropriate, and avoid doing everything on the app's main thread. In order to make the app both responsive for your users as well as a good citizen on the Android platform, take any blocking or long-running tasks off the main (UI) thread, and run them in the background instead. This includes tasks like decoding a bitmap, accessing storage, working on a machine learning (ML) model, or performing network requests.
Things to understand about background work include:
Understand Asynchronous work. This document explains asynchronous work, and helps you understand the difference between asynchronous and persistent work.
Persistent work is background work that remains scheduled through app restarts and system reboots.
Effective use of broadcasts. Much like the publish-subscribe design pattern, Android apps can send or receive broadcast messages from the Android system and other Android apps.
How to use the different techniques necessary to test asynchronous work versus testing persistent work.
Videos
Deep dive into Wear OS app architecture
Updated November 10, 2022
WorkManager: Back to the foreground
Updated October 27, 2021
Now in Android: 37 - Android 12, MAD Skills WorkManager, AndroidX, and more!
Updated April 1, 2021
WorkManager: Live Q&A - MAD Skills
Updated April 1, 2021
WorkManager: Community tip - MAD Skills
Updated March 29, 2021
WorkManager: Deprecation of GCM NM & FCM JD - MAD Skills
Updated March 22, 2021
Now in Android: 36 - MAD Skills WorkManager, AndroidX, #AndroidDevChallenge, and more!
Updated March 18, 2021
WorkManager: Advanced configuration & testing - MAD Skills
Updated March 15, 2021
WorkManager: Working in the background - MAD Skills
Updated March 8, 2021
Now in Android: 35 - Jetpack Compose Beta, Android 12, WorkManager, and more!
Updated March 5, 2021
WorkManager: Basics - MAD Skills
Updated March 1, 2021
Introduction to WorkManager - MAD Skills
Updated March 1, 2021
Now in Android: 33 - Motion Layout, AndroidX, Hilt, WorkManager, and more!
Updated February 5, 2021
Kotlin: Using WorkManager Kotlin APIs - MAD Skills
Updated January 7, 2021
Improve your App's Architecture
Updated May 13, 2018