Amad
Amad
Android is an open source and Linux-based Operating System for mobile devices such as smartphones and
tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other companies.
History Of Android : 2003–2005: Android Inc. founded; acquired by Google in 2005 to build an open
mobile OS.
2009–2011: “Cupcake” to “Ice Cream Sandwich” add on-screen keyboard, widgets, tablet UI, unified
phone/tablet design.
2013–2015: “KitKat” and “Lollipop” introduce memory optimizations, Material Design, ART runtime.
2016–2018: “Marshmallow” to “Pie” bring runtime permissions, Doze mode, multi-window, gesture
navigation.
2019–2023: Android 10–14 focus on privacy (dark theme, one-time permissions), Material You, per-app
language, predictive gestures.
1. linux kernel
2. native libraries (middleware),
3. Android Runtime
4. Application Framework
5. Applications
5. Applications
Among the layers of the Android architecture, applications are at the top. Applications that come pre-installed
on the device, like contacts, music, app store, cameras, galleries, etc., as well as the ones downloaded from the
Google Play Store, such as social applications, games, professional applications, etc., will be installed only on
this layer. Applications run within Android’s runtime environment, utilizing the classes and services provided
by the application framework. A typical Android user interacts with this layer mostly for basic functions like
accessing the Web browser, making phone calls, viewing galleries, etc. Below are a few examples of some of
the standard applications that come pre-installed on every device:
4. Application Framework
The application framework that stands on top of the native libraries and runtime layer provides us with
Application Programming Interfaces (APIs) and higher-level services. The Android Application Framework
provides classes, interfaces, and utilities that are used for the development of Android applications. Also
included in this framework is an Android Hardware Abstraction Layer (HAL), which allows the application to
communicate with hardware-specific device drivers and to manage both the UI and resources. The overall aim
of it is to provide services through which we can create a particular class and make that particular class available
for aid when creating applications. The Android framework includes the following high-level services that can
be beneficial for developing mobile applications according to our prerequisites:
3. Android Runtime
The Android Runtime Environment is an integral part of Android. It contains components such as core libraries
and the DVM (Dalvik Virtual Machine). The Android runtime, along with the libraries, powers our applications,
and is the basis for the framework.
2. Platform/Native Libraries
Several native libraries are layered on top of the Linux kernel. The Library provides the device with a set of
instructions that allow it to handle different types of data in an appropriate way. As part of Android
development, native libraries are required, and most of these libraries are open-source. It is a collection of C/C+
+ core libraries as well as Java-based libraries, which support Android development, such as Graphics, Libc,
SSL (Secure Socket Layer), SQLite, Media, Webkit, OpenGL (Open Graphic Library), Surface Manager, etc.
Here are some details about some key Android libraries that are available for Android development.
1. Linux Kernel
As with any operating system, the Linux kernel, or whatever we call it in our context, is one of the most
important components of Android’s architecture that resides at the root (bottom layer) of the entire system. It
manages all the drivers needed during the runtime of an Android device, such as camera drivers, display drivers,
audio drivers, Bluetooth drivers, and memory drivers, among others.
The Android SDK (Software Development Kit) is a collection of tools and libraries that
developers use to build Android applications. Here are the key features of the Android
SDK:
1. Access to Hardware
Android SDK allows your app to use the phone's hardware components like:
o Camera (take pictures, record videos)
o GPS (get user location)
o Accelerometer (detect phone movement/shaking)
o Microphone (record audio)
o Bluetooth/WiFi (connect to other devices)
Example: A fitness app uses the accelerometer to count steps.
2. Data Transfer
4. Background Services
Apps can run tasks in the background (even when app is not open):
o Syncing data
o Fetching notifications
o Playing music
Example: WhatsApp syncs messages in the background even when you're not using
the app.
5. SQLite
6. Widgets
Widgets are small interactive components you can place on the home screen.
Example: A weather app widget shows current temperature without opening the
app.
Android supports:
o 2D graphics : Images, animations, UI design
o 3D graphics : Games and simulations using OpenGL ES
Example: A racing game with 3D cars and tracks.
8. Cloud Support
Android Studio is the official Integrated Development Environment for Android app
development, based on IntelliJ IDEA by JetBrains.
Key Features:
Includes:
Allows developers to run and test apps on different device configurations without physical
hardware.
Features:
Uses:
Functions:
Game engines
Media processing
Hardware interfacing
9. Operating System
Windows
macOS
Linux
Android Studio works across all platforms, but iOS development is only possible on
macOS (not related to Android, but relevant for cross-platform dev).
Define Intent. Explain the term exploring Intent objects and exploring intent resolution.
An intent is a messaging object used to request any action from another app component. Intents facilitate
communication between different components in several ways. The intent is used to launch an activity, start the
services, broadcast receivers, display a web page, dial a phone call, send messages from one activity to another
activity, and so on.
TYPE OF INTENT
1. Explicit Intents:
Explicit Intents explicitly specify the target component that should be invoked. By defining the target
component's class name or package name, explicit Intents enable developers to directly communicate with a
specific activity, service, or broadcast receiver within their application.
2. Implicit Intents:
Implicit Intents do not specify a particular component but rather describe the desired action and data. They
allow developers to declare an intention without knowing which specific component will handle the request.
The Android system evaluates implicit Intents and presents the user with a list of suitable components capable
of fulfilling the requested action.
1. What is an Activity?
An Activity in Android represents a single screen with a user interface. It acts as the entry point for user
interaction and is one of the most important components of an Android application.
Creating an Activity
Starting an Activity
To launch another Activity, Intent objects are used. Intents are messaging components that facilitate
communication between different components of the app.
Explicit Intent
This is used when the target Activity is within the same application and is known by name. It is
commonly used for navigation between screens.
Implicit Intent
Used when the action to be performed is known, but the exact component (like a browser or camera) is
not. The system will determine the appropriate app or Activity to handle it.
Once the Intent is created, the new Activity is started using a system method that initiates the transition.
Each Activity goes through various states such as Created, Started, Resumed, Paused, Stopped, and
Destroyed. These are managed by lifecycle methods which help in resource management and user experience.
This fires when the system first creates the activity. On activity creation, the activity enters the Created state. In
the onCreate() method, you perform basic application startup logic that should happen only once for the entire
life of the activity. For example, binding layout or your ViewModel.
onStart()
When the activity enters the Started state, the system invokes this callback. The onStart() call makes the activity
visible to the user, as the app prepares for the activity to enter the foreground and become interactive. Use this
where the app initializes the code that maintains the UI, like starting animation or attaching listeners or
receivers.
onResume()
When the activity enters the Resumed state, it comes to the foreground, and then the system invokes the
onResume() callback. This is the state in which the app interacts with the user. The app stays in this state until
something happens to take focus away from the app. Such an event might be, for instance, receiving a phone
call, the user navigating to another activity, or the device screen turning off.
onPause()
The onPause() callback method is called when an activity is no longer in the foreground, either because another
activity has taken focus or because the user has navigated away from the app. In this method, you should
perform any necessary actions that should happen before the activity becomes partially or completely obscured,
like stopping animation or persisting UI states.
onStop()
This method is called when an activity is no longer visible to the user and is in the process of being stopped. In
this method, you should perform any necessary actions that should be done when the activity is no longer
visible. Like, releasing the resources, and unregistering listeners or receivers.
onPause() is called when an activity is losing focus, while onStop() is called when the activity is no longer
visible to the user.
onDestroy()
onDestroy() is called before the activity is destroyed. The system invokes this callback either because:
1. the activity is finishing (due to the user completely dismissing the activity or due
to finish() being called on the activity), or
2. the system is temporarily destroying the activity due to a configuration change
(such as device rotation or multi-window mode).
Sure! Here's a 7-mark theory-only answer on passing data using an Intent object in Android Mobile
Application Development (AMAD), without code:
In Android, Intent is a messaging object used to request an action from another component (such as starting an
activity, service, or broadcasting a message). It can also be used to pass data between components, especially
between activities.
1. Types of Intents
Explicit Intent: Used to start a specific component by name (e.g., moving from one activity to another
within the same app).
Implicit Intent: Used to request an action that can be handled by any app (e.g., sending an email or
opening a webpage).
4. Data Retrieval
The receiving component extracts the data using the same key with which it was sent.
This is typically done in the onCreate() method of the receiving activity or component.
Explain two ways of creating layouts with its advantages and disadvantages.
In Android, layouts define the structure and user interface (UI) of an application. There are two main ways to
create layouts:
1. XML-Based Layouts
Description:
Advantages:
Separation of UI and logic – keeps the design separate from the application code.
Easy to visualize and edit using Android Studio's Design Editor.
Reusable – XML layouts can be reused in different activities or fragments.
Better for team collaboration (designers and developers can work independently).
Disadvantages:
Description:
Layouts are created directly in Java or Kotlin code using View objects and layout containers.
All UI components are instantiated and arranged programmatically.
Advantages:
Disadvantages:
Conclusion:
In Android, the user interface (UI) is built using a hierarchy of View and ViewGroup elements. These elements
define how content is displayed and how users interact with the app.
1. View
2. ViewGroup
3. Layouts
Layouts are XML or programmatic structures that define how UI elements are arranged on the screen.
They help in designing responsive and adaptive interfaces for various screen sizes and orientations.
4. Widgets
A dialog is a small window that prompts the user to make a decision or enter additional information.
It appears on top of the current activity and pauses user interaction with the underlying screen.
Toast: A brief message that appears at the bottom of the screen to notify the user without blocking
interaction.
Snackbar: Similar to a toast but more interactive, often with an action button (e.g., “UNDO”).
7. Navigation Components
These are UI elements that help users move between screens or parts of the app.
Includes elements like navigation drawer, bottom navigation bar, and tabs.
Helps improve usability and app structure.
Displays the title, navigation options, and menu items at the top of the screen.
Provides consistent navigation and branding for the app.
9. Fragments
Arranges child views into rows and Displays one view on top of
Definition
columns like a table another, like a stack
Layout Aligns children in tabular form; Only one child is visible at a time
Behavior each cell can contain a view unless layered intentionally
More structured and complex due to Simpler, mostly used for single-
Complexity
multiple rows/columns child or layered UI
1. Absolute Layout
Definition:
Absolute Layout allows you to specify the exact x and y coordinates of each view
(in pixels) on the screen.
It positions components based on fixed positions .
Features:
o Every UI element is placed using absolute positioning ( layout_x , layout_y ).
o Positioning is not flexible across different screen sizes and resolutions.
o Deprecated in newer Android versions because it does not support
responsive design .
Example (Theory):
Imagine you want to place a button exactly 50 pixels from the left and 100 pixels
from the top of the screen. You can do that in Absolute Layout. But this button
may look misaligned on different devices because pixel density varies.
Use Case:
o Suitable only for prototypes or static screens where fixed positioning is
acceptable (rarely used in modern apps).
2. Relative Layout
Definition:
Relative Layout arranges views relative to each other or relative to the parent
layout .
Features:
o You can position elements above, below, to the left/right of other views.
o Can also align elements relative to the parent (e.g., center, top, bottom).
o Supports responsive design , making it suitable for multiple screen sizes.
o More flexible and powerful compared to Absolute Layout.
Example (Theory):
Suppose you want to place a "Submit" button below a TextField and center it
horizontally. With Relative Layout, you can easily place it below another view and
align it in the center of the parent .
Use Case:
o Login forms, settings screens, profile layouts where components need to be
aligned in relation to each other.
Comparison Summary:
Aspect Absolute Layout Relative Layout
Example (Theory) Place image exactly 100px from Place image below a TextView,
Aspect Absolute Layout Relative Layout
top centered
Resources are stored separately from the source code in the res/ (resources) directory of
the Android project. This separation allows easier management, localization, and reuse
of content across different devices and configurations (like screen sizes, languages, and
themes).
In Android, resources are external elements like images, strings, layouts, colors, and more
that are kept separate from the source code. These resources are stored in the res/
(resource) directory. This separation helps in easier maintenance, localization, and device
compatibility.
Main Resource Subdirectories
Directory
Purpose
Name
Stores images and graphic files such as .png , .jpg , .xml (shapes or
res/drawable/
selectors). Example: logo.png , button_background.xml
Contains XML files for fixed values used in the app, like strings, colors,
res/values/
dimensions, styles. Examples: strings.xml , colors.xml , styles.xml
Holds launcher icons for different screen densities. Replaces older use of
res/mipmap/
drawable for app icons. Example: ic_launcher.png
Stores XML files for menus (Options menu, Context menu). Example:
res/menu/
main_menu.xml
Used to store raw files like audio, video, or text that are accessed as raw
res/raw/
streams. Example: intro_music.mp3
Contains custom font files like .ttf or .otf for typography styling. Example:
res/font/
roboto.ttf
Used for color state list XML files to define dynamic colors based on
res/color/
states. Example: button_color.xml
When an app is built, these resource files are compiled into a binary format and accessed
using resource IDs . For example, if there is a string "Welcome" defined in
res/values/strings.xml , it can be used in the app using R.string.welcome .
In Android, system resources refer to the pre-defined resources provided by the Android operating system,
such as built-in layouts, strings, drawables, colors, styles, animations, and more.
These resources can be referenced using the android.R class, which points to the resources packaged within
the Android framework.
1. What is R ?
In Android, every resource (image, layout, string, etc.) is assigned a unique ID and stored in a class
called R.
For system resources (those provided by Android OS), we use android.R, not the project's local R.
2. Structure of Reference
android.R.<resource_type>.<resource_name>
3. Example (Theoretical)
To use the default Android OK button text, you can reference it as:
→ android.R.string.ok
To apply a default system theme, reference:
→ android.R.style.Theme_Light
To use a built-in Android icon, you might refer to:
→ android.R.drawable.ic_menu_camera
To use a standard Android layout, like a simple list item:
→ android.R.layout.simple_list_item_1
Consistency: Ensures your app uses familiar UI components already recognized by users.
Saves Time: Reduces effort by reusing what’s already available in the framework.
Smaller APK: Avoids duplicating resources, helping reduce app size.
Better Compatibility: Built-in resources are optimized for performance and accessibility across
various Android devices.
Android provides a wide range of User Interface (UI) components to design interactive
and user-friendly mobile apps. Here are four commonly used UI components:
1. TextView
3. Button
4. ImageView
What is SQLite?
1. Creating a Database
o A developer defines a custom database by extending the SQLiteOpenHelper
class.
o The database is created when the app is installed or first run.
2. Creating Tables
o Tables are created using SQL CREATE TABLE queries inside the
onCreate() method.
o Each table contains columns that define the data types (e.g., name, age,
email, etc.).
3. Inserting Data
o When the user performs an action (like filling a form), the app inserts data
using an SQL INSERT command.
4. Reading Data
o The app retrieves data using the SELECT query.
o For example, when showing a list of users, the app fetches records from the
database.
5. Updating Data
o The UPDATE command is used when users modify previously stored
information (like editing a profile).
6. Deleting Data
o The DELETE command removes unwanted records from the table.
7. Closing the Database
o After operations are complete, the database connection is closed to free up
resources.
You can create a "Notes" table with columns like ID , Title , and Content .
When the user writes a new note, it gets inserted into the database.
To show all notes, the app performs a SELECT query.
If a user edits a note, the app updates that record.
When deleting a note, the app removes it using the DELETE command.
1. Application Idea
Use the Android Emulator or a real device to run and test the app.
Check for bugs, layout issues, and performance.
3. Deployment Process
Step 8: Publish
After approval by Google, the app becomes live and available to users globally
1. HttpURLConnection
Intents are messaging objects used to request actions from other components (e.g.,
starting an activity or service).
You can share data (text, image, file, etc.) between apps using implicit intents .
Example: A user selects a photo in the gallery and shares it to a messaging app via
the “Share” button.
o The system shows a list of apps that can handle the shared data (like
WhatsApp, Gmail, etc.).
o The selected app receives the image via an Intent and displays it.
Content Providers manage access to a central data repository and allow other
apps to securely read/write data.
They use content URIs to identify data and permissions to control access.
Example: A contacts app exposes contact data using a content provider. A
messaging app can read contact names and numbers through this provider, with
permission.
Data can be shared between components (activities, services) within the same app
using Shared Preferences (key-value pairs), Internal Storage, or SQLite databases.
This method is not for sharing between apps , but for storing data to be reused
across sessions.
Apps can write files (e.g., documents, images) to external storage which may be
accessible by other apps.
Starting from Android 10+, access to shared storage is restricted due to scoped
storage for better privacy.
5. Clipboard Manager
Used to copy data (text, images) to the clipboard, which other apps can paste.
Useful for temporary data sharing, like copying a phone number from one app and
pasting it into another.