Explore tens of thousands of sets crafted by our community.
Android Services & Background Tasks
20
Flashcards
0/20
Started Service
Purpose: To perform a task without a direct user interface feedback but not instantly noticeable by the user. Example: Downloading a large file in the background.
ViewModel
Purpose: To manage UI-related data in a lifecycle-conscious way. Example: Retaining UI data after configuration changes like rotations.
Foreground Service
Purpose: To perform a task that is noticeable to the user. Example: A music player playing music while the user is in a different app.
JobScheduler
Purpose: To schedule jobs when certain conditions are met. Example: Uploading logs when the device is charging and connected to Wi-Fi.
WorkManager
Purpose: To schedule and execute deferrable background tasks that need a guaranteed execution. Example: Daily backup of app data to the cloud.
LiveData
Purpose: To observe changes in data within a view model. Example: Automatically updating the UI when the data source is changed.
Services vs Threads
Purpose: Knowing the difference helps in choosing the right approach for a task. Services are components that handle tasks without UI, while threads handle operations outside the main thread.
AlarmManager
Purpose: To trigger operations even if the app isn't running at predefined times. Example: An app that sends a notification reminder every morning.
Handler
Purpose: To handle and enqueue action or messages in a single thread. Example: Posting tasks to the main thread from a background thread to update the UI.
Bound Service
Purpose: To allow a component (like an Activity) to bind to a service for inter-process communication (IPC). Example: A music app's UI that communicates with a music-playing service.
Thread Pool
Purpose: To manage a pool of worker threads. Example: Executing multiple concurrent network operations efficiently.
BroadcastReceiver
Purpose: To allow the system and apps to send and receive broadcast messages. Example: Initiating a background service when the device completes booting.
Background Service
Purpose: To perform tasks that don't need to interact with the user. Example: Synchronizing app data with a server while the app is not actively used.
Loader
Purpose: To load data asynchronously in activities and fragments. Example: Loading a list of messages from the database without blocking the main thread.
AsyncTask
Purpose: To perform short-lasting background operations and updating the UI on completing. Example: Updating user interface with newly fetched weather data.
Intent Flags
Purpose: To control the behavior of the activity being launched. Example: Using NO_HISTORY flag so the activity isn't kept in the back stack.
IntentService
Purpose: To handle asynchronous tasks, one at a time, on a separate worker thread. Example: Handling network operations or image processing.
SyncAdapter
Purpose: To synchronize data between an Android device and a server. Example: Syncing user contacts with a server database.
ContentProvider
Purpose: To manage access to a structured set of data. Example: Providing a mechanism for data sharing between different applications.
Service Lifecycle
Purpose: To understand the lifecycle for managing services properly. Example: Knowing when to create, start, bind, unbind, and destroy a service.
© Hypatia.Tech. 2024 All rights reserved.