About Background work
Stay organized with collections
Save and categorize content based on your preferences.
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
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-12-15 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2023-12-15 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-12-15 UTC."]]