📖 2413MJET306A • Unit I • 8 Hrs

Unit I - Introduction to Android Programming

Comprehensive University Exam Preparation Notes, Model Question Answers & Comparison Matrices

🔍
📑 Quick Jump Navigation

📌 Syllabus Topics Covered

8 Hrs Weightage

📖 Comprehensive Theoretical Notes

Exam-Oriented Theory

1.1 & 1.2 Android OS Overview, Evolution, and Layered Architecture

Android OS: An open-source, Linux-based software stack created by Google and the Open Handset Alliance (OHA) designed for mobile smartphones, tablets, wearables (WearOS), TV (Android TV), and automotive systems.

The 5 Key Layers in Android Architecture:

  • 1. Linux Kernel (Foundation): Provides core system services: hardware abstraction, device drivers (Display, Camera, Bluetooth, Wi-Fi, Audio, Binder IPC), memory management, process management, and security.
  • 2. Hardware Abstraction Layer (HAL): Exposes standard C/C++ interfaces to hardware vendors, allowing the higher-level framework to interact with device hardware without knowing device-specific driver implementations.
  • 3. Native C/C++ Libraries & Android Runtime (ART):
    • Native Libraries: WebKit/Blink (browser engine), SQLite (database engine), OpenGL ES / Vulkan (3D graphics), FreeType (font rendering), Media Framework.
    • Android Runtime (ART): Replaced legacy Dalvik Virtual Machine (DVM). Uses Ahead-Of-Time (AOT) compilation and Just-In-Time (JIT) profiling to convert DEX bytecode into native machine instructions at installation/runtime, providing smoother execution and reduced battery consumption.
  • 4. Application Framework: Java/Kotlin APIs providing reusable services to apps: Activity Manager, Window Manager, Package Manager, Telephony Manager, Resource Manager, Location Manager, Notification Manager, Content Providers.
  • 5. Applications Layer (Top Layer): Native core apps (Phone, SMS, Camera, Contacts, Settings) and third-party user-installed applications.

1.3 The 4 Core Building Blocks of Android Applications

Every Android app is composed of loosely coupled components declared in AndroidManifest.xml:

  • 1. Activity: Represents a single screen with a graphical user interface (e.g., LoginActivity, UserProfileActivity).
  • 2. Service: A background component that performs long-running operations without providing a user interface (e.g., background music playback, periodic file downloading).
  • 3. Broadcast Receiver: A component that listens for and responds to system-wide broadcast announcements (e.g., ACTION_BATTERY_LOW, ACTION_BOOT_COMPLETED, CONNECTIVITY_CHANGE).
  • 4. Content Provider: Manages access to a central repository of structured data, enabling secure inter-application data sharing (e.g., querying Contacts or MediaStore via standard URI schemes).

1.4 - 1.6 API Levels, Project Structure, and AndroidManifest.xml

Android API Levels & Version Compatibility:

  • compileSdkVersion: The Android SDK version used to compile the code.
  • minSdkVersion: The absolute minimum Android OS version required to run the app.
  • targetSdkVersion: The tested Android version for which runtime behavior and modern permission models are enabled.

Android Project Directory Structure:

  • app/src/main/java/: Java/Kotlin source code packages.
  • app/src/main/res/: Application resources (layout/ for XML UI designs, drawable/ for images/vectors, values/ for strings, colors, styles).
  • app/src/main/AndroidManifest.xml: The central configuration file declaring app package name, components, hardware permissions (<uses-permission>), and intent filters.
  • build.gradle: Gradle build automation script managing external dependencies and SDK configurations.

🔑 Key Concepts & Examination Keywords

Quick Terminology
Android Runtime (ART)
The runtime environment in Android executing DEX bytecode using Ahead-of-Time (AOT) and Just-in-Time (JIT) compilation.
Dalvik Virtual Machine (DVM)
The legacy register-based virtual machine replaced by ART that used JIT compilation.
AndroidManifest.xml
The root XML configuration manifest that declares all application components, permissions, and hardware features to the OS.
Intent Filter
An XML declaration in the manifest specifying what types of implicit intents an Activity, Service, or Receiver can handle.

🎯 High-Yield Important Examination Questions

8–10 Descriptive Points Each

Q1. Explain the 5-layer architecture of the Android Operating System in detail, describing the functions of each layer and the role of ART.

10 MarksAndroid ArchitectureCore
📝 Detailed Examination Answer (10-Point Model):
  1. Overview of Android Architecture: Android OS is structured into a 5-layer software stack combining a Linux foundation with a rich Java/Kotlin application framework.
  2. Layer 1: Linux Kernel: Acts as the foundation layer handling hardware interaction, process management, memory paging, power management (Wakelocks), and low-level Binder IPC drivers.
  3. Layer 2: Hardware Abstraction Layer (HAL): Provides standard C/C++ interfaces exposing hardware capabilities (Camera, Audio, Bluetooth, Sensors) to the higher-level framework regardless of specific vendor chipsets.
  4. Layer 3: Native C/C++ Libraries: Includes core system libraries: SQLite for relational storage, OpenGL ES / Vulkan for 2D/3D graphics, WebKit for web rendering, FreeType for fonts, and SSL for cryptography.
  5. Layer 3: Android Runtime (ART): Executes Dalvik Executable (.dex) bytecode using Ahead-of-Time (AOT) compilation and profile-guided JIT compilation, providing faster app startup and smoother UI.
  6. DVM vs ART Evolution: ART compiles DEX bytecode into native machine ELF binaries during app installation/idle charging, eliminating DVM's runtime JIT translation overhead.
  7. Layer 4: Application Framework: Exposes high-level Java APIs for app development, including ActivityManager, WindowManager, ContentProviders, ViewSystem, and NotificationManager.
  8. Layer 5: Applications Layer: The topmost layer containing pre-installed system apps (Phone, Contacts, Settings) and third-party user applications downloaded from Google Play.
  9. Inter-Process Communication (Binder IPC): Enables high-speed, secure inter-process communication between application components and system framework services via shared memory.
  10. Application Sandboxing Security: Every Android app runs in an isolated Linux process assigned a unique Linux User ID (UID), preventing unauthorized memory access across apps.

Q2. Explain the 4 fundamental Building Blocks of Android (Activity, Service, Broadcast Receiver, Content Provider) with their lifecycles and practical use cases.

10 MarksAndroid Building Blocks
📝 Detailed Examination Answer (10-Point Model):
  1. Overview of Building Blocks: Android applications are constructed from four loosely coupled core components, each serving a distinct operational purpose in the mobile lifecycle.
  2. 1. Activity Component: Represents a single screen with a graphical user interface (UI); handles user interaction, UI rendering, and touch input (e.g., `MainActivity`, `CheckoutActivity`).
  3. Activity Invocation & Stack Management: Activities are managed in a Last-In-First-Out (LIFO) Back Stack and launched via Intents using `startActivity(intent)`.
  4. 2. Service Component: Performs long-running background operations without providing a user interface (e.g., playing music, background GPS tracking, downloading files).
  5. Service Types (Started vs Bound): Started Services run indefinitely until stopped (`startService()`); Bound Services provide a client-server interface bound to other components (`bindService()`).
  6. 3. Broadcast Receiver Component: Acts as an event listener responding to system-wide or app-level broadcast announcements without maintaining an active UI.
  7. Broadcast Triggers & Registration: Responds to intents like `BOOT_COMPLETED`, `BATTERY_LOW`, or `AIRPLANE_MODE_CHANGED`; registered statically in Manifest or dynamically via `registerReceiver()`.
  8. 4. Content Provider Component: Manages access to a central repository of structured data, abstracting underlying storage (SQLite, files) and enabling secure cross-app data sharing.
  9. ContentResolver & URI Addressing: Client apps interact with Content Providers using a `ContentResolver` addressing data via uniform URIs (e.g., `content://contacts/people`).
  10. Manifest Declaration Rule: All Activities (``), Services (``), Broadcast Receivers (``), and Content Providers (``) must be declared in `AndroidManifest.xml`.

Q3. Describe the structure, role, and key XML tags of AndroidManifest.xml in Android application development.

10 MarksAndroidManifest.xml
📝 Detailed Examination Answer (10-Point Model):
  1. Central Role of AndroidManifest.xml: The manifest file is the root configuration contract providing essential metadata about the app to the Android OS, Google Play Store, and build tools.
  2. Root <manifest> Tag and Package Attribute: The root element `` defining the unique application namespace and build identifiers.
  3. Hardware & System Permissions (<uses-permission>): Declares system permissions required by the application (e.g., ``, `INTERNET`, `ACCESS_FINE_LOCATION`).
  4. Hardware Feature Filtering (<uses-feature>): Specifies hardware sensors required (e.g., ``) for Google Play filtering.
  5. The <application> Container Tag: Encloses all application-level metadata including `android:icon`, `android:label`, `android:theme`, `android:allowBackup`, and component declarations.
  6. <activity> Declaration & Launcher Intent Filter: Declares activities; the main entry point activity contains `` with `` and ``.
  7. <service> & <receiver> Declarations: Declares background services and static broadcast receivers, specifying permissions and intent filters for external access.
  8. <provider> Tag & Authorities: Declares Content Providers, defining `android:name` and `android:authorities` URI namespace used by ContentResolvers.
  9. API Level & SDK Compatibility (<uses-sdk>): Historical tag (now configured in `build.gradle`) specifying `minSdkVersion`, `targetSdkVersion`, and `maxSdkVersion`.
  10. Security & Export Restrictions (android:exported): Controls whether other applications on the device can invoke this component; explicitly set `android:exported="false"` for private internal components.

⚖️ Comprehensive Comparison & Difference Tables

8+ Comparison Criteria

📊 Dalvik Virtual Machine (DVM) vs Android Runtime (ART)

Comparison ParameterDalvik Virtual Machine (DVM)Android Runtime (ART)
Compilation ModelJust-In-Time (JIT) compilation during runtime.Ahead-Of-Time (AOT) compilation + profile-guided JIT.
Bytecode Translation TimingTranslates DEX bytecode into native code dynamically while app is running.Translates DEX bytecode into native machine ELF binaries during installation.
App Execution SpeedSlower; incurs CPU translation latency every time code executes.Significantly faster; runs directly as pre-compiled native machine instructions.
App Startup TimeLonger startup times due to runtime bytecode interpretation.Faster app launch times with immediate native execution.
Storage Space RequiredSmaller storage footprint; stores only compact DEX bytecode files.Larger storage footprint (~10-20% more space for compiled ELF binaries).
Battery & CPU EfficiencyHigher battery consumption due to repetitive JIT compilation cycles.Superior power efficiency; lower CPU cycles during app execution.
Garbage Collection (GC)Frequent, stop-the-world GC pauses causing UI stutter/jank.Optimized GC with a single pause and background memory compaction.
Android OS IntroductionUsed from Android 1.0 up to Android 4.4 (KitKat).Introduced in Android 4.4, became the default runtime in Android 5.0 (Lollipop).

📊 Explicit Intent vs Implicit Intent

Comparison ParameterExplicit IntentImplicit Intent
Target SpecificationExplicitly names the exact target component class (e.g., `SecondActivity.class`).Does not name a specific class; specifies a general action to perform.
Intent Creation Syntax`new Intent(MainActivity.this, SecondActivity.class)``new Intent(Intent.ACTION_VIEW, Uri.parse("https://google.com"))`
Target ResolutionDirectly resolves to the specified Java/Kotlin class within the same app.Android OS evaluates Intent Filters across all installed apps to find matches.
Use CaseNavigating between known screens/activities within the same application.Delegating tasks to external apps (opening browser, dialing phone, camera).
App Chooser DialogNever displays an app chooser dialog.Displays Android App Chooser if multiple apps can handle the intent.
Security RiskCompletely secure; cannot be intercepted by external malicious apps.Can be intercepted if broadcast filters are not restricted.
Intent Filter RequirementTarget activity does NOT require `` in manifest.Target component MUST declare an `` to be discovered.
Action & Data FieldsTypically does not require action strings or URI data schemes.Relies heavily on `Action` (e.g., `ACTION_SEND`), `Data`, `Type`, and `Category`.

⚡ Quick Pre-Exam Revision Summary

5-Minute Recap
💡 Core Takeaways & High-Yield Summary
  • Android architecture: Linux Kernel $\rightarrow$ HAL $\rightarrow$ Native Libraries & ART $\rightarrow$ Application Framework $\rightarrow$ Applications.
  • ART uses Ahead-of-Time (AOT) compilation; DVM used Just-in-Time (JIT) compilation.
  • The 4 Building Blocks: Activity (UI), Service (background), Broadcast Receiver (events), Content Provider (data sharing).
  • API levels: `minSdkVersion` (minimum supported OS), `targetSdkVersion` (tested OS behavior), `compileSdkVersion` (build SDK).
  • `AndroidManifest.xml` declares all components, permissions (``), and intent filters.