22ISE71 - MOBILE
APPLICATION DEVELOPMENT
Prof. Parvathy.S
Dept. of ISE,
NHCE
History of Mobile Technology
Martin Cooper, an American engineer, a Motorola researcher invented the first handheld
cellular mobile phone in 1973 - father of the handheld cell phone
In 1980's, 1G was introduced
In 1991, the 2G introduced with Short Message Service (SMS) and Multimedia Messaging
Service (MMS). The data-transmission speed was very slow
In 1998, 3G was introduced to provide faster data-transmission speeds to support video calling
and internet access. HD was not supported.
In 2008 4G was released to support more demanding services such as gaming services, HD
mobile TV, video conferencing and 3D TV
5G technology?
5G
Commercially deployed worldwide since 2019–2020.
Provides high speed (up to 10 Gbps in lab tests), low latency (<10 ms), and
supports IoT, smart cities, AR/VR, autonomous vehicles, etc.
India, US, Europe, China, South Korea, and many other countries already
have 5G networks running.
Various mobile operating systems:
Android - Google
BlackBerry OS - Research in Motion (RIM)
webOS - Hewlett Packard
iOS, (iPhone OS) - Apple
Symbian - Nokia - Microsoft
Bada - Samsung
Windows Mobile Standard (non-touch screen) - Microsoft
Overview of Android
Android, a Linux based mobile OS developed by Google, primarily for touch
screen mobile devices such as smart phones and tablet computers
First completely open-source mobile OS. (Open-source software copyright holder grants
users the rights to use, study, change, and distribute the software and its source code to anyone and
for any purpose)
Android applications are written using the Java, C, C++, XML, Assembly
language, Python, Shell script, Go etc.,
Stack that includes the OS and key mobile applications, along with a set of API
Libraries for writing applications.
Available in 100+ languages
Why Android
?
Features of Android
Connectivity: GSM(Global System for • Video calling
Mobile Communications), CDMA(Code • Screen capture
Division Multiple Access), Bluetooth, WI-FI,
• Streaming media support
3G, LTE (Long-Term Evolution), GPS.
• Optimized graphics
Messaging: SMS, MMS, GCM (Google
could messaging) • External storage
Multilanguage support
Multi touch
Android Architecture
Android Architecture
The Android software stack is composed of the following
Linux kernel
Libraries
Android run time
Application framework
Application layer
Android Architecture
1. Application Layer:
Native and third-party apps are built on the application layer
by means of the same API libraries.
Some of the native applications are,
Contacts
SMS/MMS
Browser
Camera
Alarm
Calculator
Voice recorder
Calendar
Android Architecture
2. Application Framework - It provides many higher-level services to
applications in the form of Java classes. Developers can make use of these
services.
An Activity Manager that manages the lifecycle of applications
and provides a common navigation backstack (e.g. Recent buttons
list the apps/activity that were used recently)
Content Providers that enable applications to access data from
other applications or to share data (e.g. searching contacts from
whatsapp)
Android Architecture
3. Linux Kernel:
It has a wide range of code for managing the following:
Process, memory, security, network, power and hardware drivers for managing
devices like camera, keypad, display etc.,
Note: Drivers are code that helps OS to recognize the physical components of
your computer, like a printer, graphics card, mouse…
Android Architecture
4. Libraries:
libc - The C standard library or libc is the standard library for
the C programming language
OpenCORE - Media libraries support playback and recording of
audio and video formats, as well as static image files,
including MPEG4, MP3, JPG, and PNG
LibWebCore – a modern web browser engine which powers
both the Android browser and an embeddable web view
Surface Manager – provides display management functionality
Android Architecture
5. Android Run Time: Dalvik Virtual Machine
Android provides a key component called Dalvik Virtual Machine which is a kind of
java virtual machine.
Rather than use a traditional Java virtual machine such as Java ME (Java Mobile
Edition), Android uses its own custom VM, Dalvik Virtual Machine
Dalvik is a open source software, originally written by Dan Bornstein, who named it
after the fishing village of Dalvik in Iceland.
The Dalvik Virtual Machine
• The Dex compiler converts
the class files into the .dex
file that run on the Dalvik
VM. Multiple class files are
converted into one dex file.
Note:
Dalvik executable files (.dex)
Android application package
file (.apk)
Android Development Framework –
Android SDK
Android development Framework – Android SDK
Android software development kit (SDK) is the part of Android Studio.
Android SDK is "the tool" for building, compiling, testing and debugging
android applications.
The Android software development kit (SDK) includes the following,
Android API libraries (Application Programming Interface)- to access the
Android stack
Several Development tools – To compile and debug Applications and to
turn Android source code into executable Android apps
Android Emulator - to develop and test android applications without using
any physical device.
Full documentation - extensive code-level reference information to learn
Android development Framework –
Android SDK
Android Emulator:
It has all of the hardware and software features
like mobile device except phone calls.
It provides a variety of navigation and control
keys.
It also provides a screen to display your
application.
Once the application is running on it, it can use
services of the android platform like accessing
the network, playing audio, video, storing and
retrieving the data etc.,
Setting up the development environment
Android Studio, is the official Integrated Development Environment (IDE) for Android. Before
using Android Studio to develop software, the most recent Java Development Kit (JDK) is needed
to be installed
Installing the Java Development Kit:
The Java Development Kit (JDK) will allow the developer to "call" Java commands in Android
Studio.
Open the JDK website. Go to
[Link] (This is the page for all
Java downloads, which includes the most recent version of the JDK)
Click DOWNLOAD. It's a grey button near the top of the page, just below the "Java" entry in
the "Java SE Downloads" section of the page.
Check the "Accept License Agreement" box.
Setting up the development environment
Installing Android Studio
Open the Android Studio download page.
Go to [Link]
Download android studio.
Install Android Studio.
Once the setup file opens, Android Studio can be installed.
This process will differ slightly depending on your computer's operating system:
Start a new Android Studio project. Click Start a new Android Studio project on
the main page, then fill out the form by entering the necessary information and
clicking Next on each page. At this point, you are ready to begin coding your very
first Android application.
Method Invocation
2 Techniques
Direct & Indirect invocation
Direct Invocation
Identifying the component ID
Identify the component in Java part by using findviewbyID(ID)
Add action Listener,it will automatically add onClick() method
Write logic inside that onClick()
Onclick(){
logic;
}
Indirect Invocation
Write logic in Java Part
Got to design part Design
part
Add a feature called onClick ,mention the method name.
Types of Android
Applications
Types of Android Applications
There are 3 types of Android Applications,
1. Native Apps
Native apps are built for particular operating systems,
which are mostly Android or IOS.
These are available for download on Google Play Store and
for IOS Apple App Store.
Native apps are generally built to make the use of all the
Types of Android Applications
2. Web Apps
Web applications are built only to run on browsers like Chrome, Firefox, and other browsers and will work
on any OS.
The responsiveness and functionality of both the Native and web apps are almost the same.
And one of the major differences between the two is that native mobile apps can function both in the
offline mode without an active internet connection and the online mode, whereas the web apps require an
active internet connection for them to work.
Gmail, Canva, and Google Docs are the best examples of web apps.
Types of Android Applications
3. Hybrid Apps
Hybrid applications are also called Cross Platform Applications. Hybrid applications are
combinations of both native and web apps, but wrapped within a native app, giving it the
ability to have its own icon or be downloaded from an app store
For example, when we build the android application, we can also launch it on IOS.
Instagram, YONO, and Swiggy are examples of Hybrid apps.
Native Android Applications
Native apps are built for particular operating systems; to make the most of all the
features and tools of the phones such as contacts, cameras, sensors, etc.
Call incoming/ Dialing number screen
An SMS management application
A music player and picture gallery
A camera and video recording application
A calculator
An alarm clock
A calendar and contacts list
A WebKit-based web browser
The home screen
Types of Android Applications
Foreground :An application that is useful only when it’s in the foreground and is effectively
suspended when it’s not visible (E.g. PayTM, Swiggy etc.,)
Background :An application with limited interaction that, apart from when being configured,
spends most of its lifetime hidden. (E.g. App scheduling, Memory management etc.,)
Intermittent :Most well designed applications fall into this category. This includes
applications that expect limited interactivity but does most of its work in the background.
(E.g. Music player, File downloading etc.,)
Android Tools
Android Tools
The Android Emulator / Android virtual device
Dalvik Debug Monitoring Service
Android Debug Bridge
Logcat
Android Asset Packaging Tool
Android development Framework –
Android SDK
Android Emulator:
It has all of the hardware and software features
like mobile device except phone calls.
It provides a variety of navigation and control
keys.
It also provides a screen to display your
application.
Once the application is running on it, it can use
services of the android platform like accessing
the network, playing audio, video, storing and
retrieving the data etc.,
Android Tools
Android Emulator or Android virtual
device (AVD)
Android emulator provides almost
all of the capabilities of a real
Android device.
can simulate incoming phone calls
and text messages,
can simulate different network
Android Tools
Dalvik Debug Monitoring Service (DDMS)
DDMS is a debugging tool allows developers to spot bugs in applications running on either an
emulator or an actual Android device.
For example, by using the DDMS’ LogCat feature, pinpoints the exact line number on which an
error occurred regarding the state of the application and the device.
Logcat
The Logcat window in Android Studio displays system messages (error/warning/other info)
during run time and keeps a history so that developer can view older messages
When an app throws an exception, logcat shows a message followed by the associated stack
trace containing links to the line of code.
Logcat Screen
Android Tools
Android Debug Bridge (ADB)
ADB is a controller to control your device over USB from a
computer, copy files back and forth, install and uninstall
apps, run shell commands, and more.
Android Tools
Android Asset Packaging Tool
AAPT is a tool that does the following
Compile: compiles resource files into binary formats.
Link: merges all compiled files and packages them to a single
package.
Resources are the additional files and static content that your code
uses, such as bitmaps, layout definitions, user interface strings,
animation instructions, and more
Android Application components
Android Application components
Application components are the essential building blocks of an Android application. These
components are loosely coupled by the application manifest file [Link] that
describes each component of the application and how they interact among each other.
Following are the four main components that can be used in an Android application −
I. Activities (E.g. Any mobile app with one or more activities)
II. Services (E.g. Downloading/uploading data at backend)
III. Broadcast Receivers (E.g. Sending/receiving notifications)
IV. Content Providers (E.g. Sharing data among mobile apps)
Android Application components
i) Activities - An activity represents a single screen with UI components. It
is the presentation layer of any applications. For example, an email
application might have one activity that shows a list of new emails,
another activity to compose an email, and another activity for reading
emails etc.,
Syntax:
An activity is implemented as a subclass of Activity class as follows −
public class MainActivity extends Activity
{
Android Application components
An android app can have one or more activities. Every activity that the
android app uses must be declared in the [Link] file and the
main activity for the app must be declared in the manifest with a <intent-
filter> that includes the MAIN action and LAUNCHER.
<intent-filter>
<action android:name="[Link]" />//entry point
<category android:name="[Link]" />
</intent-filter>
If either the MAIN action or LAUNCHER category is not declared for the main
activity, then the app icon will not appear in the Home screen’s list of apps. If
the user forgets to declare any of the activity, then android will not be able to
detect that activity in the app.
Android Application components
ii) Services - A service is a component that runs in the background, updating your data sources,
triggering notification etc., They also perform some tasks when applications are not active (run even if the
user switches to some other app). The prime aim of a service is to ensure that the application remains
active in the background so that the user can operate multiple applications at the same time.
For example, a service might play music in the background.
Syntax:
A service is implemented as a subclass of Service class as follows in [Link]
public class backgroundmusic extends Service
{
Android Application components
iii) Broadcast Receivers - In android, Broadcast Receiver is a component that will allow an apps to receive or
deliver notifications (System oriented/application oriented notifications) to other apps.
E.g. Sending a low battery message (System oriented). Or Network connected or Incoming calls.
A Broadcast Receiver in Android is a component that allows your app to listen for and
respond to broadcast messages from:
The Android system (e.g., battery low, Wi-Fi connected, SMS received).
Other apps (e.g., a messaging app notifying your app about a new message).
Your own app (custom broadcasts between components).
Broadcast Receivers -
There are mainly two types of Broadcast Receivers:
I. Static Broadcast Receivers: receivers works even if the app is closed.
II. Dynamic Broadcast Receivers: receivers work only if the app is active or minimized.
An app has to register for receiving broadcast messages. When a new broadcast received, the
OS will check for specified broadcasts have subscribed or not based on that it will routes the
broadcasts to the apps.
Broadcast Receivers (examples)
1. Whenever the battery level goes very low,
the brightness will be reduced automatically
Some applications will automatically turned off
Not able to turn-on new app like gmail…. All these are for saving the existing
battery. The android system announcing (broadcasting) the battery level to all
other apps
2. Whenever you receive an OTP, that will be automatically fetched and entered by the
system during online payment. No need to memorize the OTP.
Broadcast Receivers
A broadcast receiver is an Android component which allows the apps to register for system events or
application events. All registered receivers (android app) for an event are notified (Toast) by the
Android runtime once this event happens.
For example, applications can register for the ACTION_BOOT_COMPLETED system event which is
fired once the Android system has completed the boot process.
Broadcast Receivers: examples
Broadcast Receivers
Broadcast Receivers
Broadcast Receivers
Registering Broadcast Receiver in Manifest XML file:
<receiver>
<intent-filter>
<action
android:name="[Link].BOOT_COMPLETED" />
<category
android:name="[Link].CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
Android Application components
iv) Content Providers - A content provider component supplies data
from one application to others on request. The data may be stored in
the file system, the database or somewhere else entirely.
A content provider is implemented as a subclass of
ContentProvider class and must implement a standard set of APIs
that enable other applications to perform transactions.
Syntax:
public class MyContentProvider extends ContentProvider
{
Android Application components
Additional Components - There are additional components which will be used
in the construction of above mentioned entities, their logic, and wiring between
them. These components are −
Views - UI elements that are drawn on-screen including buttons, Textview,
EditText etc.
Layouts - View hierarchies that control screen format and appearance of the
views. (Horizontal / Vertical)
Intents -used to start and stop Activities and Services, to broadcast messages.
Resources - External elements, such as images, files etc.,
Android Manifest File
Role of manifest file in Android
Manifest file is a XML file that works as a bridge between
the android applications and the android operating system.
Manifest file for an android application is a resource file which
contains all the details called ‘Meta Data’ about the apps that will be
accessed by the android OS
Every project in android includes a manifest file, which is
AndroidManifest. xml, stored in the root directory of its project
hierarchy.
Purpose of [Link]
The manifest file describes essential information about the app by intent-filter to the Android Operating
System.
E.g 1: To perform network operations in your application, your manifest must include the following
permissions:
<uses-permission android:name="[Link]" />
<uses-permission android:name="[Link]" />
E.G 2: To receive broadcast messages, your manifest must include the following in [Link]
<receiver android:name=".MyBroadcastReceiver“>
It is responsible to protect the application to access any protected parts by providing the permissions.
It also declares the android API that the application is going to use.
A simple [Link] file looks
like this:
1. <manifest xmlns:android="[Link]
2. <application
3. android:icon="@drawable/ic_launcher"
4. android:theme="@style/AppTheme" >
5. <activity
6. android:name=".MainActivity"
7. <intent-filter>
8. <action android:name="[Link]" />
9.
10. <category android:name="[Link]" />
11. </intent-filter>
12. </activity>
13. </application>
14. </manifest>
Role of manifest file in Android
Android Application Lifecycle
Every screen in android comprises 2 files,
1. XML file – called as ‘Layout’
2. Java file – called as ‘Activity’
An activity is a single screen with some UI
components.
Steps for creating an activity:
1. Your java file should extend “AppCompatActivity”
[Link] implementation part to “onCreate()” method
[Link] XML file to your java file using “setContentView”
e.g. setContentView([Link].activity_main);
Oncreate() method
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity
{
Protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
}
}
import [Link];
This imports the AppCompatActivity class from the AndroidX library.
AppCompatActivity is a base class for activities that use the modern Android components and features
while ensuring backward compatibility with older Android versions.
We use this instead of the older [Link].
import [Link];
This imports the Bundle class from the Android framework.
A Bundle is a collection of key–value pairs used to pass data between activities or to save the state of an
activity when it is recreated (like after screen rotation).
public class MainActivity extends AppCompatActivity
This defines a new Java class MainActivity.
The keyword extends AppCompatActivity means MainActivity inherits all properties and methods of
AppCompatActivity.
This makes MainActivity an Activity (a screen in your Android app).
@Override
protected void onCreate(Bundle savedInstanceState) {
onCreate() is a lifecycle method of an activity.
It is called when the activity is created (first launched).
The Bundle savedInstanceState contains previously saved activity state (if any).
[Link](savedInstanceState);
Calls the parent class’s (AppCompatActivity) onCreate() method.
This ensures that the system initializes the activity properly before adding your
own code.
Skipping this line would break the lifecycle flow.
setContentView([Link].activity_main);
This sets the UI layout of the activity.
[Link].activity_main refers to the activity_main.xml file inside the res/layout folder.
Whatever UI is defined in that XML file will be displayed when the activity starts.
7 major methods of Activity
Does not
exist state
1. onCreate();
onPause(),
onCreate(), onStart(, onResume()
onStop(),
2. onStart(); onDestroy()
3. onResume(); onPause()
Foreground
4. onPause(); state Paused state
onResume(
5. onStop(); onRestart )
(),
6. onRestart(); onStart(), onPause(), onStop()
onResum
7. onDestroy(); e() Background
state
Activity States
Inactive state (Does not exist)
Activity has been killed, and before it’s been launched, it’s inactive
Active state (Foreground)
Activity is at the top of the stack it is the visible, focused, foreground Activity that is
receiving user input
Stopped state (Background)
Activity isn’t visible, it ‘‘stops”
Paused state
Activity will be visible but will not have focus
Activity Stacks
Activity Stacks
Android manages activities (screens) in a stack structure (like a pile of
cards).
The top of the stack = the current active activity (the screen you see).
When you press the Back button, the current activity is popped (removed)
and the previous one resumes.
Previous Activities (Activity Stack)
All the previously opened activities are stored in a stack.
Example: If you go from Chat List → Chat Window → Settings, then "Chat
List" and "Chat Window" are below "Settings" in the stack.
Removed to free resources
Android may remove older activities from memory if resources are low.
Example: If your phone runs low on RAM, Android may remove the Chat List
screen from memory. When you go back, it will reload instead of instantly
showing.
Monitoring State Changes
onCreate(Bundle) — activity being created for the first time. Load layout, initialize objects,
restore savedInstanceState.
onStart() — activity is becoming visible (but not yet in the foreground for user interaction).
prepare UI, register broadcast receivers needed for visible UI.
onResume() — activity is now in the foreground and the user can interact with it (running). start
animations, acquire exclusive resources (camera, audio focus), start sensors.
onPause() — another activity is coming into foreground (partially obscured or losing focus). Save
transient UI state and pause animations/audio. commit small quick state saves, release
CPU-heavy updates.
onStop() — activity is no longer visible. Release heavy resources (e.g., camera, large Bitmaps) and
do longer cleanup.
onDestroy() — final cleanup before the activity is destroyed (may not always be called — system
can kill process without calling it).
onRestart() — called when an activity that was stopped is about to start again (then onStart() →
onResume() follow).
The End