Unit 1: Android fundamentals
Mobile Application Development notes · PTU syllabus (BSIT601)
On this page
Unit summary
Android runs on most of the world's smartphones, and its apps are written in Java or Kotlin. This unit covers an overview of Java and Android, how Android compares with other mobile environments, the Android software stack and application structure, the application context, intents, the activity life cycle, and supporting multiple screen sizes.
After this unit you can
- Relate Java to Android development and compare mobile platforms
- Describe the Android stack and the structure of an app
- Use context and intents
- Explain the activity life cycle and design for multiple screens
PTU syllabus topics
- Overview of Java and Android
- comparison with other environments
- Android stack and application structure
- application context
- intents
- activity life cycle
- supporting multiple screen sizes
- 1. onCreate(): Set up the screen
- 2. onStart(): Becomes visible
- 3. onResume(): User can interact
- 4. onPause(): Partly hidden
- 5. onStop(): No longer visible
- 6. onDestroy(): Activity closed
Topic 1
Overview of Java and Android
- Android: an open-source, Linux-based mobile operating system led by Google (Android Inc. acquired 2005; first phone 2008). Apps are written in Java or Kotlin (Google's preferred language since 2019) and built with Android Studio (which replaced Eclipse with the ADT plug-in).
- Java concepts used constantly: classes and inheritance (an Activity extends AppCompatActivity), interfaces (listeners such as View.OnClickListener), anonymous classes and lambdas, generics (ArrayList of String), exceptions and packages.
- 1
Java or Kotlin source and XML resources
- 2
Compiled to bytecode
- 3
Converted to DEX (Dalvik executable) by D8
- 4
Packaged with resources and manifest into an APK or App Bundle
- 5
Signed
- 6
Installed and run on ART (Android Runtime)
Topic 2
Android compared with other environments
Developer
Google and Open Handset Alliance
Apple
Source
Open source (AOSP)
Closed
Languages
Kotlin, Java
Swift, Objective-C
IDE
Android Studio (any OS)
Xcode (macOS only)
Devices
Many manufacturers, screen sizes and versions (fragmentation)
Limited Apple devices
Store
Google Play and others; side-loading allowed
App Store only (with regional exceptions)
- Cross-platform options: Flutter (Dart), React Native (JavaScript), Kotlin Multiplatform; web apps and PWAs run in the browser.
Topic 3
The Android software stack
- Applications
Phone, contacts, browser, your apps
- Java API framework
Activity manager, content providers, resource manager, notification manager, view system, location manager
- Native C/C++ libraries and Android Runtime
SQLite, OpenGL ES, WebKit, media; ART with ahead-of-time and JIT compilation
- Hardware abstraction layer
Standard interfaces to camera, Bluetooth, sensors
- Linux kernel
Drivers, memory and process management, security, power management
Topic 4
Application structure
manifests/AndroidManifest.xml
Package name, components, permissions, launcher activity
java (or kotlin)
Activities, adapters, helper classes
res/layout
XML screen layouts
res/values
strings.xml, colors.xml, themes
res/drawable and mipmap
Images and app icons
Gradle scripts
build.gradle — SDK versions and dependencies
Activities
Single screens with a user interface
Services
Background work without a UI — music playback
Broadcast receivers
Respond to system-wide events — battery low, SMS received
Content providers
Share data between apps — contacts
xml<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>Topic 5
The application context
- Context: an interface to global information about the app environment — used to access resources, start activities and services, get system services, open databases and files, and show toasts.
Obtained by
getApplicationContext()
this inside an activity
Lifetime
Whole app process
Only while that activity lives
Use for
Long-lived objects — database helpers, singletons
UI work — dialogs, layout inflation, starting activities
Risk
Cannot show themed UI
Memory leaks if stored in long-lived objects
Topic 6
Intents
- Intent: a messaging object requesting an action from another component — start an activity, start a service or deliver a broadcast.
Target
Names the exact component class
Declares an action; the system finds a suitable app
Use
Navigating within your own app
Opening a web page, dialling, sharing, taking a photo
Example
new Intent(this, ResultActivity.class)
new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.sbs.ac.in"))
java// Explicit: open ResultActivity and pass data
Intent i = new Intent(MainActivity.this, ResultActivity.class);
i.putExtra("name", "Riya");
i.putExtra("marks", 91);
startActivity(i);
// In ResultActivity
String name = getIntent().getStringExtra("name");
int marks = getIntent().getIntExtra("marks", 0);
// Implicit: dial a number
startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:01612345678")));- Intent filters in the manifest declare which implicit intents a component can handle.
Topic 7
Activity life cycle
- 1. onCreate(): Activity created — set layout, initialise views
- 2. onStart(): Becoming visible
- 3. onResume(): In the foreground, interacting with the user
- 4. onPause(): Partly hidden — save light data, pause animations
- 5. onStop(): No longer visible — release heavy resources
- 6. onRestart(): Coming back from stopped
- 7. onDestroy(): Being finished or destroyed by the system
Example
Pressing Home on a running app calls onPause() then onStop(); returning calls onRestart(), onStart(), onResume(). Rotating the screen destroys and recreates the activity unless state is saved (onSaveInstanceState or ViewModel).
Topic 8
Supporting multiple screen sizes
- Density-independent pixels (dp)
- Size layouts in dp and text in sp, not px
- Flexible layouts
- ConstraintLayout, match_parent, wrap_content, weights
- Alternative resources
- layout-land, layout-sw600dp for tablets, values-night
- Density-specific images
- drawable-mdpi, hdpi, xhdpi, xxhdpi or vector drawables
- Window size classes
- Compact, medium, expanded layouts for phones, foldables and tablets
Pixels from dp
px = dp × (dpi ÷ 160)
Example
48 dp at 480 dpi (xxhdpi) = 144 px
Key terms
- APK
- Android package file used to install apps
- ART
- Android Runtime that executes app code
- Activity
- Single screen of an Android app
- Intent
- Message requesting an action from a component
- dp
- Density-independent pixel for consistent sizing
Quick revision
- Android history; Java/Kotlin; Android Studio; build to DEX and APK.
- Android vs iOS; cross-platform frameworks.
- Stack: kernel, HAL, native libraries and ART, framework, apps.
- Project structure; manifest; activities, services, receivers, providers; context.
- Explicit vs implicit intents; life-cycle callbacks; dp, sp, alternative resources.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Name the layers of the Android stack.
- Q2.What is the AndroidManifest.xml file?
- Q3.Distinguish application context and activity context.
- Q4.Distinguish explicit and implicit intents.
- Q5.Which callback runs when an activity becomes visible?
- Q6.Why should layouts use dp instead of px?
Long-answer questions
- Q1.Explain the Android architecture with a diagram.
- Q2.Explain the structure of an Android application and its components.
- Q3.Explain intents with examples.
- Q4.Explain the activity life cycle with a diagram.
Stuck on this unit?
Message SBS on WhatsApp for help with Mobile Application Development, or to ask about studying B.Sc IT at Synetic.
