Skip to content
AD-703 (B) · Mobile Application Development/Quick Revision Short Notes

Mobile Application Development (AD-703 (B)) - Unit 2 Short Notes

How unit 2 is examined

This unit covers the building blocks of an Android app (activities, services, intents, receivers), the manifest that declares them, intent filters and permissions; no topic was asked in the supplied papers, so each is kept short.

Anatomy of an Android applications

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>An Android application is a set of loosely coupled components (activities, services, broadcast receivers and content providers) plus resources, all declared in AndroidManifest.xml and packaged in one APK.</mark>

Key points.

  1. An Activity is one screen with a user interface, and a Service runs in the background without a UI.
  2. A Broadcast Receiver responds to system or app announcements, and a Content Provider shares data between apps.
  3. The res folder holds layouts, strings and images, and the src folder holds the Java or Kotlin code.
  4. The manifest lists every component and the permissions the app needs.

Android terminologies

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>Android terminologies are the standard terms used to build apps: View, ViewGroup, Context, Intent, Activity, Fragment, Service, Manifest and APK.</mark>

Key points.

  1. A View is a basic UI element such as a Button or TextView, and a ViewGroup is a container of views such as LinearLayout.
  2. A Fragment is a reusable portion of UI that lives inside an activity.
  3. The APK is the installable package, and the Dalvik or ART runtime executes the compiled code.
  4. Resources are external files (layouts, strings, drawables) referred to through the generated R class.

Application Context

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>Context is an abstract class giving access to application-specific resources and system services, and to operations such as starting activities and broadcasting intents.</mark>

Key points.

  1. The Application Context lives as long as the app process and is obtained with getApplicationContext().
  2. The Activity Context is tied to one activity's lifecycle and is needed for UI work such as dialogs.
  3. Holding an Activity Context in a long-lived object causes a memory leak, so use the Application Context there.
  4. Context is used to get resources, start services, read preferences and access databases.

Activities

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>An Activity is a single focused screen of an app that hosts the user interface and handles user interaction.</mark>

Key points.

  1. An activity is a subclass of Activity (or AppCompatActivity) and is declared in the manifest.
  2. Its lifecycle callbacks are onCreate, onStart, onResume, onPause, onStop, onRestart and onDestroy.
  3. onCreate sets the layout with setContentView, and onPause is where unsaved data should be saved.
  4. Activities are kept on a back stack, so Back returns to the previous one.

Services

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>A Service is an application component that performs long-running work in the background and provides no user interface.</mark>

Key points.

  1. A started service is launched with startService() and runs until it calls stopSelf() or is stopped.
  2. A bound service is attached with bindService() and offers a client-server interface, ending when all clients unbind.
  3. A service runs on the main thread by default, so heavy work needs its own thread.
  4. Typical uses are music playback and file downloads, and every service must be declared in the manifest.

Intents

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>An Intent is a messaging object that requests an action from another component, used to start activities, start services and deliver broadcasts.</mark>

Key points.

  1. An explicit intent names the target class, for example new Intent(this, Second.class), and is used inside one app.
  2. An implicit intent gives an action and data, such as ACTION_VIEW with a URL, and the system picks a matching component.
  3. Extras carry data with putExtra() as key-value pairs.
  4. startActivityForResult() (now the Activity Result API) returns a result to the caller.

Receiving and Broadcasting Intents

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>A Broadcast Receiver is a component that receives broadcast intents, sent with sendBroadcast(), from the system or from other apps.</mark>

Key points.

  1. A receiver extends BroadcastReceiver and overrides onReceive(Context, Intent).
  2. It is registered either in the manifest with a receiver element or at run time with registerReceiver().
  3. Examples of system broadcasts are BOOT_COMPLETED, BATTERY_LOW and airplane-mode changes.
  4. onReceive must finish quickly because it runs on the main thread.

Android Manifest File and its common settings

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>AndroidManifest.xml is the mandatory XML file at the root of the app that describes the app to the Android system: its package, components, permissions and requirements.</mark>

Key points.

  1. The manifest element carries the package name and the application element holds the components.
  2. Each activity, service, receiver and provider is declared with its own element.
  3. uses-permission requests permissions, and uses-sdk (minSdkVersion, targetSdkVersion) sets the API levels.
  4. The launcher activity has an intent filter with MAIN and LAUNCHER.

Using Intent Filter

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>An intent filter is a manifest declaration that tells the system which implicit intents a component can handle.</mark>

Key points.

  1. It contains an action element, an optional category element and an optional data element (scheme, host, mime type).
  2. The system matches an intent only if its action, category and data all match the filter.
  3. An activity that must receive implicit intents includes the DEFAULT category.
  4. MAIN with LAUNCHER makes an activity appear on the home screen, and data filters enable deep links.

Permissions

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>A permission is a restriction that protects sensitive data or actions, and an app must declare it in the manifest and, for dangerous ones, get the user's approval.</mark>

Key points.

  1. Normal permissions, such as INTERNET, are granted automatically at install time.
  2. Dangerous permissions, such as CAMERA and READ_CONTACTS, need runtime approval from Android 6.0 (API 23).
  3. The app checks with checkSelfPermission() and asks with requestPermissions().
  4. The user's choice arrives in onRequestPermissionsResult(), and the app must cope with denial.

Last-minute revision

  • An APK contains components, resources and the manifest.
  • The four components are Activity, Service, Broadcast Receiver and Content Provider.
  • Activity lifecycle order is onCreate, onStart, onResume, onPause, onStop, onDestroy.
  • A started service uses startService() and a bound service uses bindService().
  • An explicit intent names the class, and an implicit intent names an action.
  • Receivers are registered in the manifest or with registerReceiver().
  • Every component must be declared in AndroidManifest.xml.
  • MAIN plus LAUNCHER marks the entry activity.
  • Dangerous permissions need runtime approval from API 23.
  • Use the Application Context for long-lived objects to avoid leaks.

Memory hooks

  • ASBC: Activity, Service, Broadcast receiver, Content provider.
  • Intent is the postman and the intent filter is the address on the door.
  • Normal permission: install and go; dangerous permission: ask and wait.
  • Activity lifecycle: Create, Start, Resume, then Pause, Stop, Destroy.

Coverage checklist

  • Anatomy of an Android applications: no past questions.
  • Android terminologies: no past questions.
  • Application Context: no past questions.
  • Activities: no past questions.
  • Services: no past questions.
  • Intents: no past questions.
  • Receiving and Broadcasting Intents: no past questions.
  • Android Manifest File and its common settings: no past questions.
  • Using Intent Filter: no past questions.
  • Permissions: no past questions.
Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in