1. Introduction to Android Architecture
Android is a layered architecture based on the Linux kernel. It consists of several components that work together to run applications efficiently on mobile devices.
Key Features of Android Architecture:
✅ Open-source – Can be customized by manufacturers and developers.
✅ Layered structure – Ensures modularity and efficiency.
✅ Secure environment – Uses sandboxing to protect applications.
2. Android Architecture Components (Layers)
The Android architecture is divided into five layers, from the lowest (hardware) to the highest (applications).
🔹 1. Linux Kernel (Hardware Abstraction Layer)
- The core foundation of Android, responsible for hardware interactions.
- Provides essential drivers and security for smooth device operation.
Functions of the Linux Kernel:
✔️ Process management (multitasking)
✔️ Memory management
✔️ Device drivers (Wi-Fi, Bluetooth, Camera, etc.)
✔️ Security (permissions, encryption)
📌 Example: If an app wants to use the camera, it interacts with the Camera Driver in the kernel.
🔹 2. Hardware Abstraction Layer (HAL)
- Acts as a bridge between hardware and software components.
- Provides APIs for apps to access device hardware (camera, GPS, audio, etc.).
📌 Example: Google Maps accesses GPS using the Location HAL without interacting directly with the hardware.
🔹 3. Android Runtime (ART)
- Responsible for running Android applications.
- Uses Ahead-of-Time (AOT) compilation for better performance.
Key Features of ART:
✔️ Faster app execution compared to older Dalvik VM
✔️ Better memory management
✔️ Supports Just-in-Time (JIT) compilation for optimization
📌 Example: When you install an app, ART compiles it into a format optimized for your device.
🔹 4. Native C/C++ Libraries
- Collection of precompiled libraries written in C and C++ for performance-critical tasks.
- Used by the system and apps for graphics, database, audio, video, and networking.
Important Libraries:
✔️ SQLite – Lightweight database engine
✔️ OpenGL ES – Graphics rendering
✔️ WebKit – Browser engine for web apps
✔️ Media Framework – Supports audio & video playback
📌 Example: YouTube uses the Media Framework to play videos smoothly.
🔹 5. Application Framework
- Provides high-level APIs for developers to build apps.
- Manages app lifecycle, activities, services, content providers, and notifications.
Key Components of Application Framework:
✔️ Activity Manager – Manages app lifecycle and navigation.
✔️ Window Manager – Handles app UI elements.
✔️ Content Providers – Manages data sharing between apps.
✔️ Notification Manager – Displays notifications.
✔️ View System – Manages UI components like buttons and text fields.
📌 Example: WhatsApp uses the Notification Manager to show new message alerts.
🔹 6. Applications (User Interface Layer)
- The topmost layer where Android apps run.
- Includes pre-installed system apps and third-party apps.
📌 Examples of Applications:
✔️ System Apps: Phone, Messages, Settings, Camera
✔️ User Apps: Facebook, Instagram, Uber, Netflix
3. How Android Works? (Application Execution Process)
When a user opens an Android app, the following steps occur:
🔹 Step 1: App Launch
- The user clicks on an app icon.
- The Activity Manager starts the app’s MainActivity.
📌 Example: Clicking on WhatsApp launches the chat screen.
🔹 Step 2: Dalvik/ART Execution
- The Android Runtime (ART) loads the app’s bytecode and compiles it to machine code.
- The app runs smoothly with optimized performance.
📌 Example: The Facebook app opens faster due to ART’s AOT compilation.
🔹 Step 3: UI Rendering
- The app’s XML layout is displayed using the View System.
- The Window Manager ensures smooth animations and UI elements.
📌 Example: When you scroll through Instagram, the RecyclerView UI component is used.
🔹 Step 4: Hardware Access
- If the app needs GPS, camera, or microphone, it communicates with the HAL & Kernel.
- Permissions are requested before using hardware features.
📌 Example: Google Maps asks for Location Permission before accessing GPS.
🔹 Step 5: Data Management
- If the app needs to store or retrieve data, it uses SQLite or Content Providers.
📌 Example: WhatsApp stores chat history using SQLite Database.
🔹 Step 6: Background Services
- Some apps run background tasks, such as notifications, data syncing, or music playback.
- These are managed by the Service component.
📌 Example: Spotify plays music even when the app is minimized.
🔹 Step 7: App Termination
- When the user closes the app, the Activity Manager releases resources.
- The app may remain in RAM (background mode) for quick relaunch.
📌 Example: If you reopen Chrome after closing, it loads faster due to background caching.
4. Conclusion
✅ Android has a layered architecture, ensuring modularity, security, and efficiency.
✅ The Linux kernel provides hardware abstraction, while ART compiles and executes apps.
✅ The Application Framework offers APIs for smooth app development.
✅ Apps interact with hardware through HAL, making Android highly flexible and powerful.