Android OS notes
Android OS notes
• Notification Manager:
Manages app notifications that can appear in the system status bar, alerting users to events even
if the app is in the background.
• Network and Internet APIs:
HTTP/HTTPS Communication, WebView, Media and Camera Framework
• Package Manager:
Handles app installation, updates, and permissions management.
• Bluetooth and NFC APIs:
Bluetooth API, NFC API: Enables Near Field Communication, useful for mobile payments, data
exchange, and device pairing over NFC.
• Telephony and SMS Services:
Allows apps to access telephony services like phone calls and SMS messages.
• Security and Permissions Framework:
Manages app permissions to enforce user privacy and security.
6. System Applications
System applications in Android are apps pre-installed by the device manufacturer or operating
system, providing core functionalities essential for the device to function smoothly. These apps
are part of the operating system’s essential software suite and are usually installed in the /system
partition, which is separate from the user’s data partition. System apps often have elevated
permissions and access to protected system resources, enabling them to perform tasks that
regular third-party apps cannot.
1. onCreate()
- Purpose: Initializes the activity. Called only once when the activity is created.
- Common Actions: Set up UI elements, initialize variables, and configure components like
RecyclerViews, buttons, etc.
2. onStart()
- Purpose: Marks the activity as visible to the user.
- Common Actions: Start animations or resources needed for the visible activity. This is the last
call before the activity is visible but not yet interacting with the user.
3. onResume()
- Purpose: Makes the activity interactive.
- Common Actions: Start receiving input, resume animations, or start any exclusive resources
like GPS or sensors. This is where the activity is fully on-screen and in the foreground.
4. onPause()
- Purpose: Indicates that the activity is partially obscured (e.g., by a dialog) but still visible.
- Common Actions: Pause ongoing tasks, animations, or sensitive actions. Release resources not
needed while the activity is in a paused state, like sensor listeners.
5. onStop()
- Purpose: Makes the activity fully invisible.
- Common Actions: Stop heavy operations like network calls or resource-intensive tasks. Release
or save data if needed.
6. onDestroy()
- Purpose: Called before the activity is destroyed, either because it’s being closed or due to
configuration changes.
- Common Actions: Clean up resources, cancel background tasks, or save any persistent state.
7. onRestart()
- Purpose: Called if the activity is being restarted after being stopped.
- Common Actions: Reload resources that were released during `onStop()` and prepare the
activity to be re-started.
1. Activities
An Activity represents a single screen with a user interface. It's the component that manages the
UI and is responsible for user interaction. Activities work in a stack, meaning each new Activity
starts on top of the previous one, creating a back stack that allows the user to navigate backward.
Example: Imagine an e-commerce app. When you open the app, you’re presented with a list of
products—this is managed by a "ProductListActivity." If you click on a product, the app takes you
to a new screen with product details, which is handled by "ProductDetailActivity." Here, each
screen (or "Activity") represents a different task or function in the app, allowing for an organized
flow of user interaction.
Key Characteristics:
• Each activity has its own lifecycle, including states like created, started, resumed, paused,
stopped, and destroyed.
• They are launched using intents, which are messages that request an action.
• Activities can be organized into a task, a series of activities that the user interacts with.
2. Services
A Service is a component that performs operations in the background without a user interface.
Services are used for long-running tasks, such as playing music, downloading files, or syncing
data with a server.
Key Characteristics:
Example: Suppose you’re using a music streaming app like Spotify. When you play a song and
exit the app, the music continues to play in the background. This is possible because of a
Service that keeps running even if the user isn’t actively engaging with the app’s UI. The service
handles the music playback while you perform other tasks on your device.
3. Broadcast Receivers
A Broadcast Receiver is a component that responds to broadcast messages from the system or
other applications. Broadcast messages can be events like system notifications (battery low,
connectivity change) or custom notifications sent by other apps. Broadcast Receivers enable
apps to respond to these events, even when they are not actively running.
Key Characteristics:
• Broadcast receivers do not have a user interface.
• They are registered in the AndroidManifest.xml file and can be declared as either
explicit or implicit.
• They are short-lived and execute only while receiving a broadcast.
Example: Consider a messaging app that notifies you when a new message arrives. When the
device receives a notification of a new message (via a broadcast), a Broadcast Receiver in the
app listens for this broadcast and shows a notification to inform you. Another example is a "low
battery" broadcast, which might prompt an app to reduce its background activity to save
battery.
4. Content Providers
A Content Provider manages access to a structured set of data. It provides an interface for data
sharing between applications. Content Providers are often used to store app data in a way that
allows other apps to securely access it.
Key Characteristics:
• Content providers define a set of APIs that allow other apps to query, insert, update,
and delete data.
• They can be implemented using different data storage mechanisms, such as SQLite
databases or files.
Example: The Contacts app in Android uses a Content Provider to manage your contacts'
information. This allows other apps, like messaging or email apps, to access contact data and
display contact names instead of just phone numbers. For example, if you download a third-
party messaging app, it may request permission to access your contacts through the Contacts
Content Provider to make the messaging experience more seamless.
• System Requirements:
• Minimum OS: Windows, macOS, or Linux.
• Recommended: At least 8GB RAM and SSD storage.
• Installation:
• Download Android Studio from the official Android Developer website.
• Follow the setup wizard to install necessary SDKs and tools.
• Additional Tools:
• JDK (Java Development Kit): Required for Java/Kotlin development.
• Gradle: Android’s build automation tool.
• Emulators/AVD: Virtual devices for testing apps.