Courses / Mobile Application Development (CDE-315) – BS CS 5th Semester

Week 3 Theory – Android OS – Architecture, Application Framework and Application Development

Week 3 – Android OS: Architecture, Framework and Application Development · 90 min read · 44 MCQs to check yourself

Android architecture explained in detail

Philipp Lackner – Activities and the activity lifecycle

How Dalvik and ART (Android Runtime) work

1. Android – history and versions

Android is an open-source, Linux-based operating system for phones, tablets, watches (Wear OS), TVs (Android TV / Google TV), cars (Android Automotive) and XR headsets.

Important versions and API levels

Every Android version has an API level (an integer) used by developers in minSdk, targetSdk and compileSdk.

Version Name API Year Notable for developers
1.5 / 1.6 Cupcake / Donut 3 / 4 2009 On-screen keyboard, widgets
2.3 Gingerbread 9–10 2010 NFC, better gaming
3.0 Honeycomb 11–13 2011 Tablets, Fragments, Action Bar
4.0 Ice Cream Sandwich 14–15 2011 Unified phone/tablet UI
4.4 KitKat 19 2013 ART introduced as an option
5.0 Lollipop 21–22 2014 ART default, Material Design
6.0 Marshmallow 23 2015 Runtime permissions, Doze
7.0 Nougat 24–25 2016 Multi-window
8.0 Oreo 26–27 2017 Notification channels, background limits
9 Pie 28 2018 Gesture navigation, display cutouts
10 (Q) 29 2019 Dark theme, scoped storage; names dropped publicly
11–12 R / S 30–32 2020–21 One-time permissions, Material You
13 Tiramisu 33 2022 Notification permission (POST_NOTIFICATIONS)
14 Upside Down Cake 34 2023 Stricter foreground services
15 Vanilla Ice Cream 35 2024 Edge-to-edge enforced
16 Baklava 36 2025 Adaptive layouts on large screens, live updates
17 (Cinnamon Bun) 37 2026 Must adapt to large screens, app memory limits

2. Android architecture – the software stack

Android is organised in layers. Each layer uses the services of the layer below it.

+------------------------------------------------------------+
|  System & User Apps  (Phone, Contacts, Camera, YOUR APP)    |
+------------------------------------------------------------+
|  Java/Kotlin API Framework (Application Framework)          |
|  Activity Manager | Window Mgr | View System | Content       |
|  Providers | Package Mgr | Notification Mgr | Resource Mgr   |
|  Location Mgr | Telephony Mgr                                |
+-----------------------------+------------------------------+
|  Native C/C++ Libraries     |  Android Runtime (ART)       |
|  libc, Media, SQLite,       |  + Core libraries            |
|  OpenGL ES/Vulkan, WebKit,  |                              |
|  SSL, Surface Manager       |                              |
+-----------------------------+------------------------------+
|  Hardware Abstraction Layer (HAL)                           |
|  Camera HAL | Audio | Bluetooth | Sensors | GPS              |
+------------------------------------------------------------+
|  Linux Kernel: drivers (display, camera, Wi-Fi, USB,         |
|  Binder IPC), power management, memory, process, security    |
+------------------------------------------------------------+

2.1 Linux kernel (bottom)

2.2 Hardware Abstraction Layer (HAL)

2.3 Native C/C++ libraries

Library Purpose
libc (Bionic) Android's small, fast C standard library
Media framework Playing/recording audio and video codecs (MP3, AAC, H.264)
SQLite Lightweight relational database for app data
OpenGL ES / Vulkan 2-D/3-D graphics
WebKit/Chromium Web rendering engine (WebView)
SSL / BoringSSL Secure internet communication
Surface Manager / SurfaceFlinger Composes windows on the display
FreeType Font rendering

Developers access them through framework APIs, or directly from C/C++ using the NDK (Native Development Kit).

2.4 Android Runtime (ART)

2.5 Java/Kotlin API framework (Application framework)

The building blocks developers use – the same APIs the system apps use:

Manager / system Role
Activity Manager Manages activity lifecycle and the back stack
Window Manager Manages windows and what appears on screen
View System UI widgets: TextView, Button, EditText, lists, layouts
Content Providers Share data between apps (contacts, media)
Resource Manager Access to non-code resources: strings, layouts, images, colours
Notification Manager Displays alerts in the status bar
Package Manager Information about installed apps
Location Manager GPS and network location
Telephony Manager Phone state, network info

2.6 Applications (top)

System apps (Phone, SMS, Contacts, Browser, Camera) and user apps. Android treats them equally – a user can replace the default keyboard, browser or SMS app.

3. Android application components

Every app is built from four main components, declared in AndroidManifest.xml:

Component Purpose Base class Example
Activity A single screen with a user interface Activity / AppCompatActivity Login screen, inbox
Service Long-running work in the background without UI Service Music playback, file download
Broadcast Receiver Responds to system-wide or app broadcasts BroadcastReceiver Battery low, SMS received, boot completed
Content Provider Manages and shares app data with other apps ContentProvider Contacts, MediaStore

Supporting concepts:

4. The activity lifecycle

An activity moves through states as the user opens, leaves and returns to it. The system calls callback methods:

        onCreate()  ->  onStart()  ->  onResume()   [RUNNING – visible and interactive]
                                          |
                     another activity comes in front
                                          v
                                      onPause()     [partly visible / losing focus]
                                          v
                                       onStop()     [not visible]
                     /                    |                    \
           user returns            system needs memory        finish()/back
          onRestart() ->            process killed             onDestroy()
          onStart() -> onResume()
Callback When called Typical use
onCreate() Activity is first created setContentView, find views, initialise data
onStart() Becomes visible Start UI-related updates
onResume() In foreground, user can interact Resume camera, sensors, animations
onPause() Losing focus (dialog, another activity) Pause video, save light data quickly
onStop() No longer visible Release heavy resources, save data
onRestart() Coming back from stopped Refresh
onDestroy() Being destroyed (finish or configuration change) Final clean-up

Back stack: activities are kept in a stack (LIFO). Starting a new activity pushes it on top; pressing Back pops (destroys) it and resumes the one below.

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "LIFE";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.d(TAG, "onCreate");
    }
    @Override protected void onStart()   { super.onStart();   Log.d(TAG, "onStart"); }
    @Override protected void onResume()  { super.onResume();  Log.d(TAG, "onResume"); }
    @Override protected void onPause()   { super.onPause();   Log.d(TAG, "onPause"); }
    @Override protected void onStop()    { super.onStop();    Log.d(TAG, "onStop"); }
    @Override protected void onDestroy() { super.onDestroy(); Log.d(TAG, "onDestroy"); }
}

Rotating the phone (a configuration change) destroys and recreates the activity – week 7.

5. Android build process and application development

Build process

Kotlin/Java source --(kotlinc/javac)--> .class bytecode --(D8/R8)--> classes.dex
Resources (res/, manifest) --(AAPT2)--> compiled resources + R class
DEX + resources + native libs --(Gradle packaging)--> APK / AAB --(apksigner)--> signed APK

Key files a developer edits

File Contains
AndroidManifest.xml Package/app info, components, permissions, intent filters
MainActivity.kt Logic of the screen
res/layout/*.xml UI layouts
res/values/strings.xml, colors.xml, themes.xml Text, colours, styles
app/build.gradle.kts minSdk, targetSdk, compileSdk, versionCode, versionName, dependencies
android {
    namespace = "com.example.studentinfo"
    compileSdk = 36
    defaultConfig {
        applicationId = "com.example.studentinfo"
        minSdk = 24          // lowest Android version supported (7.0)
        targetSdk = 36       // version the app is tested against (Play requires 36 from Aug 2026)
        versionCode = 1      // integer, must increase with every Play release
        versionName = "1.0"  // shown to users
    }
}
dependencies {
    implementation("androidx.appcompat:appcompat:1.7.0")
    implementation("com.google.android.material:material:1.12.0")
}

Android Jetpack and modern development

Steps to develop an Android app

  1. Create project in Android Studio (choose template, package name, minSdk).
  2. Design screens in XML layouts (or Compose).
  3. Write Kotlin/Java code in activities/fragments; connect views with findViewById or View Binding.
  4. Declare components and permissions in the manifest.
  5. Add libraries in Gradle.
  6. Run and debug on emulator/real device (Logcat, breakpoints).
  7. Test, build a signed release AAB/APK and publish.

Short and long questions

1. Write any four milestones in the history of Android.

Model answer

2003 Android Inc. founded; 2005 acquired by Google; 2007 announced with the Open Handset Alliance; 2008 first phone HTC Dream (Android 1.0); 2014 Lollipop introduced Material Design and ART; 2015 Marshmallow introduced runtime permissions.

2. What is an API level? Give the API levels of Android 6.0, 8.0 and 16.

Model answer

An API level is an integer that uniquely identifies the framework API revision offered by an Android version; developers use it in minSdk, targetSdk and compileSdk. Android 6.0 = API 23, Android 8.0 = API 26, Android 16 = API 36.

3. Draw and explain the Android architecture (software stack) in detail.

Model answer

Android is a layered software stack (draw five layers):

1. Linux kernel – the base layer. A modified Linux kernel provides device drivers (display, camera, keypad, Wi-Fi, Bluetooth, audio, USB, flash memory), process and memory management, power management, networking and security. Each app runs as a separate Linux user in its own sandbox. The Binder driver provides inter-process communication, and the low-memory killer frees RAM by ending background processes.

2. Hardware Abstraction Layer (HAL) – standard interfaces that expose hardware capabilities (camera, audio, sensors, Bluetooth, GPS) to the framework. Vendors implement HAL modules for their chips, so the upper layers stay the same on all devices.

3. Native C/C++ libraries – Bionic libc, Media framework (audio/video codecs), SQLite (database), OpenGL ES/Vulkan (graphics), WebKit/Chromium (web rendering), SSL (security), Surface Manager (display composition), FreeType (fonts). Apps use them through Java/Kotlin APIs or the NDK.

3b. Android Runtime (ART) – each app runs in its own process with its own ART instance executing DEX bytecode. ART uses ahead-of-time compilation at install plus JIT and profile-guided compilation, efficient garbage collection and debugging support. It replaced Dalvik (JIT-based) in Android 5.0. Core libraries provide Java language APIs.

4. Java/Kotlin API framework – the building blocks for apps: Activity Manager (lifecycle and back stack), Window Manager, View System (UI widgets), Content Providers (data sharing), Resource Manager (strings, layouts, images), Notification Manager, Package Manager, Location Manager and Telephony Manager.

5. Applications – system apps (Phone, Contacts, SMS, Camera, Browser) and user-installed apps, all built on the same framework APIs; users may replace default apps.

Advantages of this design: portability across hardware, security through sandboxing, reuse of components and a rich, consistent API for developers.

4. What is the role of the HAL?

Model answer

The Hardware Abstraction Layer provides standard interfaces (camera, audio, Bluetooth, sensors) between the Android framework and device-specific drivers, so manufacturers can implement them for their hardware without changing the higher layers.

5. Differentiate between Dalvik and ART.

Model answer

Dalvik (until Android 4.4) used Just-In-Time compilation every time the app ran, causing slower start-up and more battery use. ART (default from Android 5.0) uses Ahead-Of-Time compilation at install time plus JIT and profile-guided optimisation, giving faster apps, better garbage collection and lower battery use; both run DEX bytecode.

6. List the layers of the Android architecture from bottom to top.

Model answer

(1) Linux kernel, (2) Hardware Abstraction Layer (HAL), (3) Native C/C++ libraries and Android Runtime (ART), (4) Java/Kotlin API framework (application framework), (5) System and user applications.

7. What is the purpose of AndroidManifest.xml?

Model answer

It declares the app's package/namespace information, all components (activities, services, receivers, providers) with intent filters, required permissions, hardware features, the launcher activity, app icon, label and theme. The system reads it before running any component.

8. Name the four main components of an Android application with one example each.

Model answer

Activity – a login screen; Service – background music playback; Broadcast Receiver – reacting to "battery low" or "SMS received"; Content Provider – the Contacts provider sharing contacts with other apps.

9. Explain the activity lifecycle with a neat diagram. Which methods are called when (a) the app is launched, (b) the user presses Home, (c) the user returns, (d) the user presses Back, and (e) the device is rotated?

Model answer

An activity passes through the states Created, Started (visible), Resumed (foreground, interactive), Paused (partly visible), Stopped (hidden) and Destroyed. The system calls callbacks at each transition (draw the diagram: onCreate → onStart → onResume → running; onPause → onStop → onDestroy; onStop → onRestart → onStart).

  • onCreate() – first creation; call setContentView, initialise views and data.
  • onStart() – the activity becomes visible.
  • onResume() – the activity is in the foreground and receives input.
  • onPause() – focus lost (dialog, multi-window, another activity starting); pause animations and video.
  • onStop() – no longer visible; release heavy resources and save data.
  • onRestart() – called before onStart() when returning from the stopped state.
  • onDestroy() – final call before the activity is destroyed (finish() or configuration change); the system may also kill the process without calling it when memory is low.

(a) Launch: onCreate → onStart → onResume. (b) Home: onPause → onStop. (c) Return: onRestart → onStart → onResume. (d) Back: onPause → onStop → onDestroy. (e) Rotation (configuration change): onPause → onStop → onDestroy, then a new instance onCreate → onStart → onResume; UI state is preserved with onSaveInstanceState or a ViewModel.

Activities are kept on a LIFO back stack; understanding the lifecycle prevents crashes, data loss and wasted battery.

10. What is the back stack?

Model answer

The back stack is a LIFO stack of activities in a task. A newly started activity is pushed on top and gets focus; pressing Back pops and destroys the top activity and resumes the previous one.

11. List the activity lifecycle callback methods in order.

Model answer

onCreate(), onStart(), onResume(), onPause(), onStop(), onRestart() and onDestroy(). Normal start: onCreate → onStart → onResume; leaving: onPause → onStop → (onDestroy); returning: onRestart → onStart → onResume.

12. Explain how an Android application is built, from source code to an installable APK, and describe the steps of developing an Android app in Android Studio.

Model answer

Build process: (1) Kotlin/Java source files are compiled by kotlinc/javac into Java bytecode (.class). (2) The D8 dexer converts the bytecode into DEX bytecode (classes.dex) for ART; in release builds R8 also shrinks, optimises and obfuscates code. (3) AAPT2 compiles resources (layouts, strings, drawables) and the manifest and generates the R class with resource IDs. (4) Gradle with the Android Gradle Plugin packages DEX files, compiled resources, assets and native libraries into an APK (or an AAB for Google Play). (5) The package is zip-aligned and digitally signed – with a debug key for testing or a release keystore for publishing. Build variants (debug/release) and product flavours control this process.

Development steps: (1) Create a project in Android Studio – choose a template (Empty Views Activity), application ID (package name), language (Kotlin/Java) and minSdk. (2) Design screens in XML layouts with the Layout Editor (ConstraintLayout, TextView, Button) or in Jetpack Compose. (3) Write logic in activities/fragments, connecting views using findViewById or View Binding. (4) Declare components, permissions and intent filters in AndroidManifest.xml. (5) Add libraries (AndroidX, Material, Retrofit) in build.gradle.kts and sync. (6) Run and debug on an emulator or a real device using Logcat and breakpoints. (7) Test, then generate a signed release AAB/APK and publish. Modern apps follow the recommended MVVM architecture with Jetpack libraries (ViewModel, Room, Navigation, WorkManager).

13. Why must an APK be signed?

Model answer

Signing proves the identity of the developer and guarantees the APK has not been altered. Android refuses to install unsigned APKs, and updates must be signed with the same key as the installed version.

14. Differentiate between minSdk, targetSdk and compileSdk.

Model answer

minSdk is the lowest API level on which the app can be installed; targetSdk is the API level the app is designed and tested for (the system applies that version's behaviours, and Google Play requires a recent target); compileSdk is the API level of the SDK used to compile the code, which decides which APIs are available at compile time.

This lesson ends with a quiz of 44 MCQs. Open the lesson on PrepOasis to take it and save your progress.

Previous: Week 2 Lab 2 – Create a Mobile-Friendly Web Page with Headings, Images, Links and a Form · Next: Week 3 Lab 3 – Student Information App: Change Image and Name from Resource and String Folders

All lessons in Mobile Application Development (CDE-315) – BS CS 5th Semester