Android Application Framework
Covers the deck Android Application Framework: app folder structure, AndroidManifest.xml, resources, the four app components, intents, content providers and resolvers, sandboxing and Binder, permission levels and the Activity lifecycle.
Why Know the App StructureSearch on YouTube
The deck covers six topics: app folder structure, AndroidManifest.xml, resources, Android components, the Activity lifecycle and permissions.
There are two ways to pentest a mobile app. Both need this knowledge.
- Through the interface. Open the app and give inputs through its screens (activities). Check its security, try different payloads, intercept the traffic, then modify it and add payloads.
- Reverse engineer the APK. Get the source code and analyse it. This is also how static malware analysis works. You must understand the app structure to read it.
Android ComponentsSearch on YouTube
An Android app has four main components.
| Component | Job |
|---|---|
| Activity | The UI. Handles user interaction with the phone. An app can have more than one activity. |
| Service | Background processing for the app |
| Broadcast Receiver | Handles communication between the Android OS and the app (system events) |
| Content Provider | Handles data and database management operations |
All Students Bring Coffee
Activity, Service, Broadcast Receiver, Content Provider.
Alarm app exampleSearch on YouTube
| Part of the alarm app | Component |
|---|---|
| Screen to set or cancel the alarm | Activity |
| Save the alarm to a file or DB; store, retrieve and work on it | Content Provider |
| Keep checking in the background whether set time matches clock time | Service |
| When the times match, the alarm event rings the alarm (event handling) | Broadcast Receiver |
The 2025 end sem asked this pattern for a "destination alarm" app (12 marks). Map each feature to one component, as in the table above.
App Folder StructureSearch on YouTube
The Android Studio demo shows the project tree:
app/
manifests/
AndroidManifest.xml
java/
com.example.<app>/ (Java or Kotlin source, e.g. MainActivity)
res/
drawable/ (bitmap images: jpg, png)
layout/ (activity_main.xml)
mipmap/ (launcher icons, ic_launcher.webp)
values/ (colors.xml, strings.xml, themes)
xml/
Gradle Scripts/ (build.gradle, proguard-rules.pro, ...)Android Manifest FileSearch on YouTube
AndroidManifest.xml:
- sits at the root of the project, with exactly this name;
- describes essential information about the app to the Android build tools (to build the APK), the Android OS and Google Play;
- declares the components of the app: all activities (launch info, permissions, intents used for communication), services, broadcast receivers and content providers.
A trimmed version of the sample manifest on the slide:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.SEND_SMS"/>
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/Theme.ActivityHello">
<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>Manifest in forensics and malware analysisSearch on YouTube
- In static malware analysis, check the permissions. Example: a game app asking for the contacts or call list is suspicious.
- Check whether a service tag runs continuously in the background.
ResourcesSearch on YouTube
Resources are the extra files and static content the code uses: bitmaps, layout definitions, animation instructions and so on.
| Folder | Contents |
|---|---|
drawable | Bitmap files (jpeg, png, etc.) |
layout | XML files that define the UI layout (text boxes, buttons, etc.) |
values | XML files with simple values such as strings, integers and colours |
Developers sometimes put sensitive data such as usernames and passwords in values (for example strings.xml). Reverse engineering the APK reveals them. This matters in forensics and pentesting.
ActivitySearch on YouTube
An Activity represents a single screen with a user interface.
- An app can have more than one activity.
- All activities are declared in the manifest.
- The main activity is declared with an
<intent-filter>that has the MAIN action and the LAUNCHER category. - The main activity is the first screen the phone shows the user.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>IntentSearch on YouTube
An Intent is a messaging object that requests an action from another app component. It enables communication between components (activities, services, broadcast receivers, content providers).
An intent object contains:
- Action: the mandatory part. A string naming the action to perform.
- Category: optional. A string with extra information about the kind of component that should handle the intent.
Two types of intentsSearch on YouTube
| Type | What it names | Use | Example |
|---|---|---|---|
| Explicit intent | The exact component | Start a component in the same app; you know which activity or service to start | Open a new activity in response to a user action; start a service; deliver a broadcast |
| Implicit intent | No specific component, only a general action | Lets a component from another app handle it | Show a location on a map by passing coordinates; dial a call; open a web page |
Content ProviderSearch on YouTube
A Content Provider supplies content or data to apps, from the Android system or from other apps.
Use it when one app must share data with, or access data from, a system or user-installed app. Example: WhatsApp accessing contacts or making a call.
Operations through a content provider:
- insert, update and delete data in a database
- read and write the contact list
- access photos, play music, and so on
The content provider hides which app or location accesses the data, and where the data comes from. Its data can live in a database, in files or come from the network.
Content ResolverSearch on YouTube
Example: App 2 wants the contact list from App 1.
- App 2 provides a URI (Uniform Resource Identifier) for the contact list.
- The URI is passed to the content resolver.
- The resolver resolves the content from the content provider's central repository.
- Through the content provider, App 1 accesses the contact list.
- The contacts return to App 2 as a cursor.
PermissionsSearch on YouTube
Permissions protect the privacy of the Android user.
- Apps must request permission to access sensitive user data (contacts, SMS) and some system features (camera, internet).
- Depending on the feature, the system grants the permission automatically or prompts the user.
- By default, no app may do anything that harms other apps, the OS or the user. This covers reading or writing the user's private data, reading or writing another app's files, network access and keeping the device awake.
- An app declares the permissions it needs with
<uses-permission>tags in its manifest. (The slide writes<user-permission>; the real tag is<uses-permission>.)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.snazzyapp">
<uses-permission android:name="android.permission.SEND_SMS"/>
</manifest>SandboxingSearch on YouTube
Each app gets:
- a separate instance with a unique ID (Linux user ID)
- separate resources
- a separate DVM
One app cannot access the resources of another. If a malicious app brings in malware, the malware stays inside its own instance.
Sandboxing does not hold on rooted phones. All apps can get superuser privilege there.
- Sandboxing works by running apps in different processes with different Linux IDs.
- It is implemented at kernel level. So it applies to native apps and OS apps alike.
Binder (IPC)Search on YouTube
Processes need an IPC (inter-process communication) framework to exchange data and signals. Android uses Binder.
- Binder is a service that lets one process access resources of another process or app securely.
- Intents and content providers are built on top of the Binder framework.
- Example: an app in process A uses a service in process B. A is the client and B is the server. WhatsApp reading the contact list from the database works this way.
Permission LevelsSearch on YouTube
The protection level decides whether a runtime permission request is needed.
| Level | When granted | Who grants | Example |
|---|---|---|---|
| Normal | Install time | System, automatically; user cannot revoke | Set time zone |
| Signature | Install time, only if the requesting app is signed with the same certificate as the app that defines the permission | System, automatically (same keystore, usually same company, so trusted) | Apps from one developer sharing a feature |
| Dangerous | Run time (Android 6.0+) | User must explicitly allow | Send SMS, read contacts |
Normal permissions cover access to data or resources outside the app sandbox that pose little risk to privacy or device operation.
Dangerous permissions can affect user privacy or normal device operation.
Dangerous permission groups (from the slide)Search on YouTube
| Group | Permissions |
|---|---|
| CALENDAR | READ_CALENDAR, WRITE_CALENDAR |
| CAMERA | CAMERA |
| CONTACTS | READ_CONTACTS, WRITE_CONTACTS, GET_ACCOUNTS |
| LOCATION | ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION |
| MICROPHONE | RECORD_AUDIO |
| PHONE | READ_PHONE_STATE, CALL_PHONE, READ_CALL_LOG, WRITE_CALL_LOG, ADD_VOICEMAIL, USE_SIP, PROCESS_OUTGOING_CALLS |
| SENSORS | BODY_SENSORS |
| SMS | SEND_SMS, RECEIVE_SMS, READ_SMS, RECEIVE_WAP_PUSH, RECEIVE_MMS, READ_CELL_BROADCASTS |
| STORAGE | READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE |
Each name is prefixed by android.permission. (groups by android.permission_group.).
Runtime permission modelSearch on YouTube
- On Android 6.0 (API level 23) and higher, the user is not told about permissions at install time. The app asks for dangerous permissions at run time (Deny or Allow).
- Up to Android 5.1.1 (API level 22), the user had to grant all dangerous permissions at install time.
- If an app update needs new permissions, the user must accept them before the update.
Activity LifecycleSearch on YouTube
Reference for the theory: the Android developer guide page on the activity lifecycle.
| Callback | What happens | YouTube example |
|---|---|---|
onCreate() | Activity is created and initialised for the first time | You tap YouTube; Android creates the video activity, loads the layout, initialises buttons, player, variables |
onStart() | Activity becomes visible on the screen | The video screen is visible but may not accept input yet |
onResume() | Activity comes to the foreground and is ready for interaction | You can tap Play, pause, scroll, like, comment |
onPause() | Activity is losing focus | An incoming call or a dialog appears over YouTube |
onStop() | Activity is no longer visible | You switch to another full-screen app |
onDestroy() | Activity is destroyed | You press Back, or Android destroys it to reclaim resources |
The lifecycle diagram also has onRestart(). It runs when a stopped activity comes back, before onStart(). If an app with higher priority needs memory, the system can kill a paused or stopped app's process. When the user returns, it starts again at onCreate().
Good use of the lifecycle callbacks helps the app avoid:
- crashing if the user gets a phone call or switches to another app;
- using system resources when the user is not active in it;
- losing the user's progress if they leave and come back later;
- crashing or losing progress when the screen rotates between landscape and portrait.
Typical scenario: a fitness app loses data on rotation or on an incoming call. Rotation destroys and recreates the activity. The fix is to save state in onPause() (or onSaveInstanceState()) and restore it in onCreate().
Quick self-testSearch on YouTube
Name the four Android app components and their roles.
Activity (UI and user interaction), Service (background processing), Broadcast Receiver (OS-to-app event communication), Content Provider (data and database management).
Map an alarm app's features to components.
Set or cancel screen: Activity. Saving alarms to a file or DB: Content Provider. Watching the clock in the background: Service. Ringing when time matches: Broadcast Receiver.
What does AndroidManifest.xml declare, and why check it in malware analysis?
It declares all activities, services, receivers, providers, permissions and intent filters. In static analysis, look for excessive permissions (a game reading call logs) and services that run constantly in the background.
How is the launcher activity marked in the manifest?
With an <intent-filter> containing the action android.intent.action.MAIN and the category android.intent.category.LAUNCHER.
Explicit vs implicit intent?
An explicit intent names the exact component and starts something in the same app. An implicit intent declares only a general action, so a component in another app can handle it, for example showing a location on a map.
How does a content resolver return contacts to another app?
App 2 passes the contacts URI to the content resolver. The resolver reaches App 1's content provider, which reads the data and returns it to App 2 as a cursor.
How is sandboxing implemented, and when does it fail?
Each app runs in its own process with its own Linux user ID and its own VM, enforced at kernel level. It fails on rooted phones, where apps can get superuser privilege.
What is Binder?
Android's IPC framework. It lets one process use another process's resources securely. Intents and content providers are built on it.
Compare normal, signature and dangerous permissions.
Normal: low risk, granted automatically at install, cannot be revoked. Signature: granted at install only if both apps share the same signing certificate. Dangerous: affect privacy, user must allow at run time on Android 6.0 (API 23) and later.
Which callback runs when an incoming call appears over an app?
onPause(), because the activity is losing focus. If it becomes fully hidden, onStop() follows.
- Two pentest routes: test through the UI with intercepted traffic, or reverse engineer the APK for source.
- Four components: Activity, Service, Broadcast Receiver, Content Provider.
- The manifest declares components, intent filters and
<uses-permission>tags; launcher activity uses MAIN and LAUNCHER. - Resources live in
res/drawable,res/layout,res/values;valuesmay leak hardcoded secrets. - Explicit intents name a component in the same app; implicit intents name an action for any app.
- Content providers share data by URI through a content resolver, returning a cursor.
- Sandboxing uses separate Linux IDs, processes and VMs; Binder is the secure IPC beneath intents and providers.
- Permission levels: normal, signature, dangerous (runtime from API 23); lifecycle runs onCreate, onStart, onResume, onPause, onStop, onDestroy.