Programming of Mobile Terminals
Programming of Mobile Terminals
Step
At A
Time
HND 2025
PROGRAMMING OF MOBILE TERMINAL
Detailed Lesson notes with practical exercises and applications in Mobile Application
Programming.
Table of Contents
MODULE 1................................................................................................................................4
GENERALITIES ON MOBILE DEVELOPMENT.............................................................4
SECTION 1 – GENERALITIES OF MOBILE TERMINALS........................................4
1.1 Introduction.................................................................................................................4
1.2 Types of Mobile Computing Devices...................................................................4
Mobile Operating Systems (Mobile OS)..........................................................................6
Early Mobile OS................................................................................................................7
1.3 Mobile Computing - Major Advantages....................................................................8
SECTION 2 – ANDROID OPERATING SYSTEM........................................................10
2.1 History of the Android Operating System..............................................................10
2.2 Features of the Android Operating System............................................................11
2.3 Android Architecture:...............................................................................................11
2.4 Security and Privacy.................................................................................................14
2.5 Mobile Security Threats............................................................................................14
SECTION 3 – iOS ENVIROMENT..................................................................................16
1
3.1 History and Overview of the iOS System................................................................16
3.2 Features of the iOS System................................................................................16
3.3 Hardware Platform of the iOS System.............................................................16
3.4 Development Platform of the iOS System........................................................16
3.5 Security and Privacy...........................................................................................17
SECTION 4 – WEB APPLICATIONS FOR MOBILE PLATFORMS........................18
4.1 Differences between Web, Native and Cross-Platform Apps.........................18
4.1.3 Cross-platform applications..................................................................................20
Conclusions.......................................................................................................................21
4.2 Tools for building web applications..................................................................21
SECTION 5 – MOBILE AND WEB APPLICATION DEVELOPMENT
PLATFORMS......................................................................................................................22
5.1 Some Mobile App Development Frameworks..................................................22
SECTION 6 – INTRODUCTION TO ANDROID PROGRAMMING WITH JAVA 27
6.1 Prerequisites of Android Programming..................................................................27
6.2 Android Studio Environment Installation And Configuration.............................29
6.3 SDK MANAGER.......................................................................................................31
6.4 Creating Android Virtual Device with AVD Manager.................................................34
6.5 Android - Application Components................................................................................36
SECTION 7 – MY FIRST ANDROID APPLICATION.................................................42
7.1 App Basics..................................................................................................................42
7.2 Hello World! Android Application..........................................................................42
7.3 Anatomy of Android Application.............................................................................45
7.4 The Main Activity File..............................................................................................47
7.5 The Manifest File.......................................................................................................47
7.6 The Strings File..........................................................................................................49
7.7 The Layout File..........................................................................................................49
7.8 Running the Application...........................................................................................50
SECTION 8 – ANDROID CODENAMES, TAGS AND BUILD NUMBERS..............51
SECTION 9 – ANDROID LAYOUTS AND HOW TO USE THEM.............................51
IUGET/2022-2023/BTECH/MOBILE_APPLICATION_DEV 2
SECTION 10 – ANDROID CONTROLS AND EVENT HANDLERS..........................51
SECTION 11 – ANDROID WITH PHP AS API.............................................................51
SECTION 12 – ANDROID AND DATABASE................................................................52
SECTION 14 – OTHER ANDROID PROJECTS...........................................................52
TUTORIALS................................................................................................................................54
3
MODULE 1
GENERALITIES ON MOBILE DEVELOPMENT
1.1 Introduction
A mobile communication device is a small, portable electronic device, with wireless
communication capabilities, which is easy to carry around. Some mobile terminals can send
and receive signals over a radio link while being connected to a base station. Mobile PCs, cell
phones and PDAs, as well as multifunctional appliances, e.g. smart phones (cell phone and
PDA) considered as mobile terminals.
Mobile data terminals feature a screen on which to view information and a keyboard or
keypad for entering information and may be connected to various peripheral devices.
Today’s mobile devices are multifunctional devices capable of hosting a broad range of
applications for both business and consumer use. Smartphones and tablets enable people to
use their mobile device to access the Internet for email, instant messaging, text messaging and
Web browsing, as well as work documents, contact lists and more.
Mobile devices are often seen as an extension to your own PC or laptop, and in some cases
newer, more powerful mobile devices can even completely replace PCs. And when the
devices are used together, work done remotely on a mobile device can be synchronized with
PCs to reflect changes and new information while away from the computer.
4
different types of operating system like as Apple iOS, Windows Mobile, Blackberry, and
Google’s Android.
PDAs have largely been rendered obsolete by the rise in popularity of smartphones and
tablets, but they still retain a presence in niche markets (A niche market is the subset of the
market on which a specific product is focused). Examples of PDA devices through the years
have included the Palm Pilot, Revo, Sony Clie, Hewlett-Packard Jornado, Casio Cassiopedia,
Compaq iPaq and Toshiba Pocket PC.
b) Smartphones
Smartphones combine a mobile phone and a handheld computer into a single device.
Smartphones allow users to access and store information (e.g. e-mail) and install programs
(applications) while also being able to use a mobile phone in one device. For example, a
smartphone could be a mobile phone with some PDA functions integrated into the device or
vice versa. Examples of smartphones over the years have included the Apple iPhone,
Samsung Galaxy, Microsoft and Nokia Lumia, Sony Ericsson, Palm Treo, Blackberry, Nokia
T-Mobile Sidekick, Torq, Motorola Q, E-Ten, HP iPaq and I-mate.
5
c) Tablet PCs
Tablet PCs are an evolution of the notebook computer
with touchscreen LCD screens that can be utilized with
your fingertips or with a stylus. The handwriting with a
stylus is digitized and can be converted to standard text
through handwriting recognition, or it can remain as
handwritten text. The stylus can also be used to type on a
pen-based key layout where the lettered keys are
arranged differently than a QWERTY keyboard. Tablet
PCs may also offer a removable keyboard as an
additional input option. Examples of tablet PCs have included Apple iPad, Microsoft Surface
and Surface Pro, Samsung Galaxy Tab, Samsung Nexus, Amazon Kindle Fire HD and
Lenovo Yoga.
i) Apple iOS
Apple’s iOS mobile operating system powers the company’s line of mobile devices like the
iPhone, iPad, iPod touch, and Apple TV. Apple iOS was originally called the iPhone OS but
was renamed in 2010 to reflect the operating system’s evolving support for additional Apple
devices. The current version of iOS as of April 2023 is the iOS 16.5.
ii) Google Android
Google Android is a mobile operating system based on Linux that has quickly become the
biggest competitor to Apple iOS in the mobile device market. Google originally released
Android’s source code under open-source licenses, and today the company continues to
6
develop the mobile OS privately prior to major update releases that are made available to
OEMs and the public. Manufacturers of Android-powered smartphone and tablet devices
include Samsung, Sony, Asus, Techno, Itel, Oppo, Amazon, HTC, LG, as well as Google
itself amongst others. The current version of the Android OS as of April 2023 is the Android
13 which was released in August 2022.
Early Mobile OS
While not as frequently encountered in today’s market, some of the earlier generation mobile
OSes have included:
iv) Palm OS
Since the introduction of the first Palm Pilot in 1996, the Palm OS platform has provided
mobile devices with essential business tools, as well as capability to access the Internet or a
central corporate database via a wireless connection. Link: Palm OS Web site
v) Symbian OS
Symbian OS had become a standard operating system for smartphones and is licensed by
more than 85 percent of the world’s handset manufacturers before it was discontinued in
2014. Symbian OS was the most widely used smartphone operating system in the world until
2010, when it was overtaken by Android. The Symbian OS is designed for the specific
requirements of 2.5G and 3G mobile phones. Examples of smartphones running on the
Symbian OS are Nokia N95, Nokia XpressMusic.
vi) Linux
The first company to launch phones with Linux as its OS was Motorola in 2003. Linux has
been seen as a suitable option for higher-end phones with powerful processors and larger
7
amounts of memory. Examples of some smartphones using the Linux OS are PinePhone,
Volla Phone and Pro1 X.
vii) MXI
MXI is a universal mobile operating system that allows existing full-fledged desktop and
mobile applications written for Windows, Linux, Java and Palm to be enabled immediately on
mobile devices without any redevelopment. MXI allows for interoperability between various
platforms, networks, software and hardware components.
Location Flexibility: This has enabled users to work from anywhere as long as there is a
connection established. A user can work without being in a fixed position. Their mobility
ensures that they are able to carry out numerous tasks at the same time and perform their
stated jobs.
Saves Time: The time consumed or wasted while travelling from different locations or to the
office and back, has been slashed. One can now access all the important documents and files
over a secure channel or portal and work as if they were on their computer. It has enhanced
telecommuting in many companies. It has also reduced unnecessary incurred expenses.
Enhanced Productivity: Users can work efficiently and effectively from whichever location
they find comfortable. This in turn enhances their productivity level.
Ease of Research: Research has been made easier, since users earlier were required to go to
the field and search for facts and feed them back into the system. It has also made it easier for
field officers and researchers to collect and feed data from wherever they are without making
unnecessary trips to and from the office to the field.
Entertainment: Video and audio recordings can now be streamed on-the-go using mobile
computing. It's easy to access a wide variety of movies, educational and informative material.
With the improvement and availability of high speed data connections at considerable cost,
one is able to get all the entertainment they want as they browse the internet for streamed
data. One is able to watch news, movies, and documentaries among other entertainment offers
8
over the internet. This was not possible before mobile computing dawned on the computing
world.
Streamlining of Business Processes : Business processes are now easily available through
secured connections. Looking into security issues, adequate measures have been put in place
to ensure authentication and authorization of the user accessing the services. Some business
functions can be run over secure links and sharing of information between business partners
can also take place. Meetings, seminars and other informative services can be conducted using
video and voice conferencing. Travel time and expenditure is also considerably reduced.
9
SECTION 2 – ANDROID OPERATING SYSTEM
Android is a mobile operating system based on a modified version of the Linux kernel and
other open-source software, designed primarily for touchscreen mobile devices such as
smartphones and tablets.
2.1 History of the Android Operating System
Android Inc was founded in Palo Alto, California in 2003 by Rich Miner, Nick Sears, Chris
White, and Andy Rubin. It was developed with objective to make “smarter mobile devices
that are more aware of its owner’s location and preferences.” Google bought Android in 2005
and everything changed. The hardware that supports android software is based on the ARM
architecture platform. ARM is a family of RISC architectures for computer processors,
configured for various environments. The android is an open-source operating system that
means that it’s free and anyone can use it. The android has got millions of apps available that
can help you manage your life one or another way and it is available to low cost in the market
for that reason android is very popular.
NAME VERSION NUMBER(S) RELEASE DATE
No official codename 1.0 September 23, 2008
1.1 February 9, 2009
Cupcake 1.5 April 27, 2009
Donut 1.6 September 15, 2009
Eclair 2.0 – 2.1 October 26, 2009
Froyo 2.2 – 2.2.3 May 20, 2010
Gingerbread 2.3 – 2.3.7 December 6, 2010
Honeycomb 3.0 – 3.2.6 February 22, 2011
Ice Cream Sandwich 4.0 – 4.0.4 October 18, 2011
Jelly Bean 4.1 – 4.3.1 July 9, 2012
KitKat 4.4 – 4.4.4 October 31, 2013
Lollipop 5.0 – 5.1.1 November 12, 2014
Marshmallow 6.0 – 6.0.1 October 5, 2015
Nougat 7.0 – 7.1.2 August 22, 2016
Oreo 8.0 – 8.1 August 21, 2017
Pie 9 August 6, 2018
Android 10 10 September 3, 2019
Android 11 11 September 8, 2020
10
Android 12 12 October 2021.
Android 13 13 August 2022
11
2.3.1 Linux kernel:
The android uses the powerful Linux kernel and it supports a wide range of hardware drivers.
The kernel is the heart of the operating system that manages input and output requests from
the software. This provides basic system functionalities like process management, memory
management, device management like camera, keypad, display etc the kernel handles all the
things. Linux is really good at networking and it is not necessary to interface it to the
peripheral hardware. The kernel itself does not interact directly with the user but rather
interacts with the shell and other programs as well as with the hardware devices on the
system.
2.3.2 Libraries:
It is on top of a Linux kennel there is a set of libraries including open-source web browsers
such as WebKit, library libc. These libraries are used to play and record audio and video. The
SQLite is a database that is useful for the storage and sharing of application data. The SSL
libraries are responsible for internet security etc.
12
2.3.3 Android Runtime:
The android runtime provides a key component called Dalvik Virtual Machine which is a kind
of java virtual machine. It is specially designed and optimized for android. The Dalvik VM is
the process virtual machine in the android operating system. It is a software that runs apps on
android devices.
The Dalvik VM makes use of Linux core features like memory management and
multithreading which is in java language. The Dalvik VM enables every Android application
to run its own process. The Dalvik VM executes the files in the .dex format.
The android emulator has all of the hardware and software features like mobile devices except
phone calls. It provides a variety of navigation and control keys. It also provides a screen to
display your application. The emulators utilize the android virtual device configurations. Once
13
your application is running on it, it can use services of the android platform to help other
applications, access the network, play audio, video, store, and retrieve the data.
14
Mobile malware and spyware security threats can access a device s private data without a user
s knowledge or consent and can also perform malicious actions without the user knowing,
including transferring control of the device to a hacker, sending unsolicited messages to the
device s contacts, making expensive phone calls on smartphones, and more.
15
SECTION 3 – iOS ENVIROMENT
3.1 History and Overview of the iOS System
iOS is a mobile operating system developed and distributed by Apple Inc. It was originally
released in 2007 for the iPhone, iPod Touch, and Apple TV. It is the world's second-most
widely installed mobile operating system, after Google’s Android. It is the basis for three
other operating systems made by Apple: iPadOS, tvOS, and watchOS. It is proprietary
software, although some parts of it are open source under the Apple Public Source License
and other licenses.
Major versions of iOS are released annually. The current stable version, iOS 16.5 (As of May
2023), was released to the public on May 18, 2023. It brought many user interface changes,
including all-new personalized Lock Screens, Focus filters, Shared Photo Library, and game-
changing messaging features to iPhone, the ability to place widgets on the home screen, a
compact UI for both Siri and phone calls, and the ability to change both the default web
browser and email apps.
16
The SDK is a free download for users of Mac personal computers. It is not available for
Microsoft Windows PCs, this means that to be able to develop iOS apps and test them
efficiently, you MUST own a MacOS computer with XCode installed. The SDK contains sets
giving developers access to various functions and services of iOS devices, such as hardware
and software attributes. It also contains an iPhone simulator to mimic the look and feel of the
device on the computer while developing. New versions of the SDK accompany new versions
of iOS
The ability to change your default browser: While it’s not a privacy or security change per
se—Apple’s Safari browser is pretty good for security and privacy—the ability to change
your default browser in iOS 16 is a welcome change for many.
Indicator light if an app is accessing your camera or microphone: It’s already available on
the Mac, but iOS 16 has now added a new feature that allows you to tell if an app is recording
you using your camera or mic—via an indicator light in the status bar.
Face recognition: FR and scene and object detection are done completely on your device
rather than in the cloud. So Apple doesn’t know what’s in your photos. And apps can access
your photos only with your permission.
Limit Access to Photos and Location: iOS 14 includes a couple of new ways that you can
give apps certain permissions, but only up to a point. The idea is that there are some apps you
trust a bit more than others in terms of looking at your photos or tracking where you are.
Sniff Out Bad Passwords: Apple has been able to sync the passwords and other login
credentials for your various accounts across all of your Apple hardware via iCloud for a while
now; this applies to macOS as well as iOS. To see what Apple has stored in the cloud from
your iPhone, choose Passwords from Settings.
17
Limit How Apps Track You: Another change in iOS 14 is that apps will have to specifically
request permission to track you across other apps and sites.
Mobile Web applications also refer to applications for mobile devices that require only a Web
browser to be installed on the device. They typically use HTML and Ajax (and, increasingly,
HTML5 components), although they may make use of augmented rich Internet application
(RIA) technologies, such as Flash, JavaFX, and Silverlight, but are not written specifically for
the device.
Which type is best depends on your goals and ideas. But making the right choice is crucial for
financial and business success. In this article, we look at all three types of mobile apps in
detail. By the end, you’ll have a better grasp of what to expect from these three types of
mobile apps.
18
WhatsApp, Spotify, Facebook and Instagram. Instagram and WhatsApp are our top choice
they are available for both iOS and Android, but these apps are entirely different and are
unique to each system. WhatsApp for iOS is completely different from WhatsApp on
Android.
Native apps are the gold standard of mobile development. Written with platform-specific
approaches and technologies, native apps can show outstanding performance.
Pros:
Faster than web apps
Greater functionality as they have access to system resources
Can work offline
Safe and secure — native apps must first be approved by the app store
Easier to build due to the availability of developer tools, interface elements and SDKs
Cons:
More expensive to build than web apps
Compatibility with different platforms (i.e. iOS and Android) usually means designing
and building the app from scratch
Expensive to maintain and update
It may prove difficult to get a native app approved by the app store as Google
PlayStore requires $25 lifetime fee while Apple Store requires $99 annual fee for
developers and $299 for Enterprises and the procedure of getting your apps to the
store in one hell of a battle.
When thinking about a web app, imagine a website turned into a mobile application. That’s
pretty much all there is to them.
Pros:
19
Do not need to be downloaded or installed — web apps function in-browser
Easy to maintain — they have a common codebase regardless of mobile platform
Will update themselves
Quicker and easier to build than mobile apps
Do not require app store approval, so can be launched quickly
Cons:
Do not work offline
Slower than mobile apps, and less advanced in terms of features
May not be as discoverable as mobile apps as they are not listed in a specific database,
such as the app store
Quality and security is not always guaranteed — web apps don’t need to be approved
by the app store
Before considering this option though, you should check it out for yourself first. If this is the
sort of experience you’re looking to deliver with your project, then by all means choose a web
app.
Advantages
Shareable code. Certain parts of code (up to 80% at times) can be shared across devices. This
can increase the speed of development, resulting in the need for fewer developers.
20
Disadvantages
Still requires some native code. Parts of the code for cross-platform apps can be shared
between platforms. However, the parts that cannot be shared still need to be written in a
native language.
Performance concerns. Some parts of cross-platform applications are interpreted on the go.
This influences the overall speed and performance of you application, meaning it will run a
lot slower than a native app.
Frameworks and plugins. Everything within a cross-platform app relies on frameworks and
plugins. This can affect application performance and design since it puts limits on what your
app can do.
21
SECTION 5 – MOBILE AND WEB APPLICATION DEVELOPMENT PLATFORMS
Mobile apps are more expensive to develop than web apps, and because they are platform-
specific, launching an app across different platforms pretty much means starting from scratch
in terms of design and development. However, they are much faster, and tend to be more
advanced in terms of features and functionality.
Native mobile apps are built using specific languages and Integrated Development
Environments (IDE) depending on the intended platform.
Apple devices run on the iOS native operating system, so Apple apps are built
using either Objective-C or Swift, and the XCode IDE.
Native apps for Android are written in Java and are commonly built using the
Android Studio or Eclipse IDE.
Apple and Google also provide their own development tools, interface elements and software
development kits (SDK) which developers can use to build native mobile apps.
22
2. Native Script
NativeScript is an open-source framework to develop mobile apps on the Apple iOS and
Android platforms. It is empowered with Angular, Typescript, JavaScript, CSS, and Vue.js.
NativeScript is a preferable framework to reduce the code and time of the app loads on the
system. Many leading companies love using Native Scripts for its strong web empowerment
platform.
Some of the Native Scripts features are:
Native user interface without WebViews
Full direct access to Android & iOS APIs
Cross-platform application
Mission-critical business support
Robust backend support
3. React Native
React Native is the best JavaScript library to build native applications for all devices and
platforms. It is used to develop applications for Android, Android TV, iOS, macOS, tvOS,
Web, Windows. With React Native, you can develop rich applications for both iOS and
Android. It also allows creating platform-specific versions of various components allowing
easy using of single codebase across various multiple platforms. This community-driven JS
library was introduced by Facebook in 2018. In order to develop apps with React Native, you
should have a basic knowledge of JavaScript, familiar with HTML and CSS and finally,
worked with React before.
Some of the React Native features are:
Low-code
Compatible third-party plugins
Declarative API for predictive UI
Supports iOS and Android
4. Xamarin
Xamarin is one of the top mobile app development frameworks and it is .Net based. This
native platform is introduced by Microsoft. Being a cross-platform and open source app
building platform, Xamarin offers a development ecosystem with backend, API, components,
etc. It is a .Net developer platform supported by various tools, libraries, and programming
23
languages. With Xamarin developers, you can build native applications with the support of an
active community for Android, tvOS, watchOS, iOS, macOS, and Windows.
Some of the Xamarin features are:
A strong community of 60,000 contributors
Versatile backend infrastructure
Diagnostic tools
Application loader
Android SDK manager
Storyboard files
Google emulator manager
5. Ionic
Ionic helps you to build interactive hybrid and Progressive Web Applications along with
cross-platform applications. This open source framework offers premium services for creating
applications. Ionic covers building applications for the web, Android, and iOS. Besides,
while working in Ionic, you can constantly create applications and ship them to the
deployable locations. Ionic Studio is the lightning version of Ionic and it is quite powerful.
You can install it locally to have an easy visual development environment.
With its out of box features, ionic is always seen as ideal platform over the other mobile app
development frameworks.
Intuitive UI components
Faster development time
Powerful & stable development platform
Evergreen community of 5 Million developers
Complete control over app building
6. Adobe PhoneGap
Adobe and Apache together sponsor Adobe PhoneGap which is used widely for Android
development. This top mobile development framework uses HTML5, CSS3 and JavaScript
for cross-platform development. Core at its heart, Adobe PhoneGap is an open-source desktop
application and you can link the apps to the mobile devices.
24
Some of the Adobe PhoneGap features are:
Open Source
Flexibility
Compatible on all the platforms
Ease of Development
Strong Backend
7. JQuery Mobile
JQuery Mobile is a user interface system based on HTML5. This web is touch-optimized and
used to build highly responsive applications for smartphones, tablets as well as desktops.
JQuery mobile has ThemeRollar offering highly customizable themes. Besides, this top
mobile app development framework enables you to create highly branded websites.
Some JQuery features are:
Built on JQuery Core
Lightweight size
Configured with HTML5
Automatic initialization
Powerful theming framework
Simple API
8. Mobile Angular UI
The Mobile Angular UI is the magical fusion of HTML5, Bootstrap and Angular JS. If you
already know Twitter Bootstrap and Angular JS, you can learn Mobile Angular UI in no time.
This mobile UI framework offers the basic mobile development components that are missing
from Bootstrap 3. Some of these components are overlays, switches, sidebars, scrollable
areas, etc. The fastclick.js and overthrow.js are the prime libraries of Mobile Angular UI.
25
9. Flutter
Flutter is a UI toolkit by Google help in building native applications for the web, mobile, and
desktop. This UI toolkit is featured with fully customized widgets, which support to create
native applications in a short period. Besides, the Flutter’s layered architecture ensures a
faster rendering of components. Flutter apps are developed using the Dart programming
language. Some of the striking Flutter features are:
26
SECTION 6 – INTRODUCTION TO ANDROID PROGRAMMING WITH JAVA
Android applications can also be developed using the Java language using the Android
Software Development Kit. Once developed, Android applications can be packaged easily and
sold out either through a store such as Google Play, SlideME, Opera Mobile Store, Mobango,
F-droid and the Amazon Appstore. is an integer value that uniquely identifies the framework
API revision offered by a version of the Android platform.
Java or Kotlin?
Java:
o Pros:
Java is a very old language so one can find too many resources to learn
that language, also if you stuck somewhere you can easily find the
solution by googling it.
If you are a computer science student you have to learn java because
it’s in the syllabus.
I think in java one can more deeply understand the oops concepts
(which is mentioned in the 3no. column) and understanding oops are
very much important.
o Cons:
With java, you have to write a lot of code.
With java one have to write too much code to perform some operations
but in Kotlin it has some inbuilt feature to handle those tasks.
27
Kotlin:
o Pros:
Google declared Kotlin as an official language for android
development.
Most of the companies are switching to Kotlin from java.
One has to write lesser code in Kotlin compare to java.
Kotin has some features that can handle a critical task in very lesser
code.
o Cons:
There are not any such disadvantages of Kotlin.
Personal Opinion: No doubt Kotlin the best language for android development there is
nothing to argue about. If you started android development with java, you have to shift it to
Kotlin one day. But In my opinion, If anyone can understand an object-orientated
programming language properly, It’s very easy for his/her to learn another language. Coding
and started learning with java may be harder than Kotlin but with java one can learn the core
concepts more deeply and also can get more resources than Kotlin and If one can learn the
main concepts properly then learning Kotlin and started development in Kotlin is a very easy
task for him/her. In the end, language is just a way to execute ideas.
28
6.2 Android Studio Environment Installation And Configuration
You will be required to download the necessary tools, SDKs and setup files to setup the
environment for development. You can use a macOS, Windows or a Linux platform for your
Android Application Development. All required packages, tools and other required files can
be downloaded from the internet. Following are the names of the files, along with their
descriptions that you will be required for developing Android apps.
a) Java Development Kit (JDK)
Android SDK works on Java SE Development Kit(JDK). Therefore, first your system must
have JDK installed. If you don't have it on your system, you can download it from here.
Note: Make sure you download proper JDK based upon your system configurations as there
are separate setup files for macOS, Windows and Linux platform.
So the first requirement for setting up the environment is that JDK must be installed on your
system. Once you are done with this, you can go for the next step.
You can download the complete Android Development Environment bundle(Android Studio
+ SDK) from the link here.
Once you have finished with installing JDK and downloading Android Studio IDE setup file,
double click on the .exe file (setup file) of the Android Studio. It'll prepare the file for setup
and will ask you for the location where you want to install it, as shown in image below.
29
Select an appropriate location and click on Next button.
30
Click on Install button. It will start installing as shown below.
Click on Next button. Android Studio has been installed directly and it is ready for use. Click
on finish button and Android Studio will open. Android Studio will automatically get the
location of the Android SDK if it is in the same location as itself. But if it fails to discover,
then it'll ask you to browse to the Android SDK's location.
Generally when you launch the Android Studio for the first time, it will open the Android
SDK Manager window, to prompt you to install the required packages for android
development. But if that does not happen, you can open the SDK Manager by going to Tools
→ Android → SDK Manager or click on the icon in the Android Studio toolbar.
Launch your SDK Manager, and you'll get to see the list of currently installed items. It will
also list all the new items & Updates available for already installed items for your system.
31
From here, you can check the required Build tools, SDK Tools, Platform Tools, SDK
Platforms, Samples for SDK, System Images (for AVD), Documentations, Sources for
Android SDK and Extra Packages for your development. It requires internet connection to
download the packages (most are of large size) so make sure you have one.
SDK Tools and Build-tools contain packages to build your Android Application and
several updates/patches from Google for better Application Development.
For specific (version) of Android, you have to download additional packages from the
section SDK Platforms. You can easily understand which API Level/Android
Version you want to install, as there is a list with Android version names listed, you
just have to select one and click on OK. In the previous image, you can see some
packages of 22 that we have installed on our system, and there is also Update available
for it. So lets see which packages do we have to install onto our machine:
1. SDK Platform: Android SDK platform contains packages/libraries to develop
& build Android Application for specific versions. To compile your
Application against specific version, to load specific widgets, views and tools
for compilation, is done by SDK Platform. Hence, whenever you want to
32
download packages for any new Android version like 8.0 or 7.0, always select
and download SDK Platform for it.
2. System Image: To create an AVD(Android Virtual Device) for any specific
API, you should download a System Image as per your system type (either 32-
bit or 64-bit OS). For Android Smart Phone, Wear & TV, separate images are
required which are also available for downloading. If your application is
working with some play-service features like Google MAPs and all, then to
test your application with them, you've to download Google API System Image
as well.
3. Optional Packages: Samples for SDK, Sources for Android SDK &
Documentation for an are optional. SDK manager also lets you download few
samples for any particular SDK platform and Source for API level. If
Documentation is there, you can download the documentation that contains
information about specific classes and methods for that API level. If you
require them, then you can select them for download else don't.
4. Scroll down in SDK Manager, and you will see Extras section, which contains
additional packages/libraries/services that are required/helpful for application
development. You can download, if you think you need any. As of now, we
advice you to ignore them.
We hope you've selected your required tools and packages to install, click on OK or Install.
This will open another window as shown in below image, select the Accept License radio
button and then click on Install Packages button in the lower right corner of the SDK
Manager window, this will start downloading your selected packages. The installation will
take time, so be patient. You'll be asked to restart the ADB when all packages get installed in
your system, Click YES for it.
33
This is all about the SDK Manager. In one line:
It lets you download your required Android Version Packages and Tools for Application
Development".
34
It will open AVD Manager with a list of created virtual devices as shown in below image. It
may be empty for you now as you haven't created any device as of now. To create a new
device, click on Create Virtual Device button at the bottom-left corner.
It will open a window to Select Hardware type for your virtual device. This list contains
almost all the Android devices with their respective settings. Select any one out of all the
devices listed, with your required configuration (like Size of the screen, Resolution and
Density) and click on Next.
35
Next you will be asked to select System Image that will be the running Android Version for
your newly created virtual device. You can choose any Android system images that are
already available in your Android Studio, or Download the one you want, by clicking on the
Download option available with the names. Recommended section will list the best choices
available as per the latest updates available. x86 Images contain images that are mostly used
and Other Images section contain system images with Google Play Services. Choose as per
your required configuration (We've selected 21). Click on Next once you are done.
There are following four main components that can be used within an Android application −
They dictate the UI and handle the user interaction to the smart phone screen.
36
2 Services
They handle background processing associated with an application.
3 Broadcast Receivers
They handle communication between Android OS and applications.
4 Content Providers
They handle data and database management issues.
Activities
An activity represents a single screen with a user interface, in-short Activity performs actions
on the screen. 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. If
an application has more than one activity, then one of them should be marked as the activity
that is presented when the application is launched.
Broadcast Receivers
Broadcast Receivers simply respond to broadcast messages from other applications or from
the system. For example, applications can also initiate broadcasts to let other applications
know that some data has been downloaded to the device and is available for them to use, so
this is broadcast receiver who will intercept this communication and will initiate appropriate
action.
37
public class MyReceiver extends BroadcastReceiver {
public void onReceive(context,intent){}
}
Content Providers
A content provider component supplies data from one application to others on request. Such
requests are handled by the methods of the ContentResolver class. The data may be stored in
the file system, the database or somewhere else entirely.
We will go through these tags in detail while covering application components in individual
chapters.
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 −
S.N Components & Description
o
1 Fragments
Represents a portion of user interface in an Activity.
2 Views
UI elements that are drawn on-screen including buttons, lists forms etc.
3 Layouts
View hierarchies that control screen format and appearance of the views.
4 Intents
Messages wiring components together.
5 Resources
External elements, such as strings, constants and drawable pictures.
6 Manifest
38
Configuration file for the application.
Next window will list down all the configured settings for final verification. Here, you can
give your AVD a name for identification, can change device type and API configuration and
can also setup size, orientation as well as Graphics for your AVD.
39
Click on Show Advanced Settings and you will see more advanced settings for your virtual
device as shown in image below. Here you have settings for Camera, Network, Memory
(RAM & Heap) and Storage (Internal & External) and Virtual Device Frame.
You can configure your device as per your requirements and click on Finish. Android Studio
will immediately start building AVD with the selected configurations & might take some
time. When it completes, AVD Manager will list out your virtual device in the available
devices list as shown in below image.
40
From the Action column(last column of the table), you can perform several actions like
Launch AVD and Edit AVD configurations etc. Launch your first AVD by clicking Start
icon(green play icon). It will start a Virtual Device just like an Android Device as shown in
below image. Side toolbar contains buttons to perform actions like volume up-down, change
orientation, go back, go to home or recent & more. You can also turn the power off for the
virtual devices using the power button and to close the virtual device select close button.
Now you have your own Android Virtual Device running on your system where you can test
various Android Application Projects. You can have more than one virtual devices in your
AVD manager as per your project requirements. Similarly you can also create AVD for
devices like Android TV and Android Wear for testing.
41
SECTION 7 – MY FIRST ANDROID APPLICATION
In the previous sections, we learned how we can setup our system for Android Application
Development and how to create an AVD(Android Virtual Device) to test our applications. So
now in this tutorial, we will be creating our first Android Application and will try to
understand the basics of Android Application development.
In simple words we can say, that the backend will be handled by the class which extends the
Activity class, and the frontend i.e. the User interface is defined in the layout XML file.
42
You can start your application development by calling start a new android studio project. in a
new installation frame should ask Application name, package information and location of the
project.−
After entered application name, it going to be called select the form factors your application
runs on, here need to specify Minimum SDK, in our tutorial, I have declared as API23:
Android 6.0(Mashmallow) −
43
The next level of installation should contain selecting the activity to mobile, it specifies the
default layout for Applications.
At the final stage it going to be open development tool to write the application code.
44
7.3 Anatomy of Android Application
Before you run your app, you should be aware of a few directories and files in the Android
project −
45
Sr.No Folder, File & Description
.
1 Java
This contains the .java source files for your project. By default, it includes an
MainActivity.java source file having an activity class that runs when your app is
launched using the app icon.
2 res/drawable-hdpi
This is a directory for drawable objects that are designed for high-density screens.
3 res/layout
This is a directory for files that define your app's user interface.
4 res/values
This is a directory for other various XML files that contain a collection of
IUGET/2022-2023/BTECH/MOBILE_APPLICATION_DEV 46
resources, such as strings and colours definitions.
5 AndroidManifest.xml
This is the manifest file which describes the fundamental characteristics of the app
and defines each of its components.
6 Build.gradle
Following section will give a brief overview of the important application files.
The main activity code is a Java file MainActivity.java. This is the actual application file
which ultimately gets converted to a Dalvik executable and runs your application. Following
is the default code generated by the application wizard for Hello World! application −
package com.example.helloworld;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
47
declare your component in this file, then it will not be considered by the OS. For example, a
default manifest file will look like as following file −
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tutorialspoint7.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The <activity> tag is used to specify an activity and android:name attribute specifies the fully
qualified class name of the Activity subclass and the android:label attributes specifies a string
to use as the label for the activity. You can specify multiple activities using <activity> tags.
The action for the intent filter is named android.intent.action.MAIN to indicate that this
activity serves as the entry point for the application. The category for the intent-filter is
named android.intent.category.LAUNCHER to indicate that the application can be launched
from the device's launcher icon.
The @string refers to the strings.xml file explained below. Hence, @string/app_name refers
to the app_name string defined in the strings.xml file, which is "HelloWorld". Similar way,
other strings get populated in the application.
Following is the list of tags which you will use in your manifest file to specify different
Android application components −
48
<activity>elements for activities
<service> elements for services
<receiver> elements for broadcast receivers
<provider> elements for content providers
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
49
This is an example of simple RelativeLayout which we will study in a separate chapter. The
TextView is an Android control used to build the GUI and it have various attributes like
android:layout_width, android:layout_height etc which are being used to set its width and
height etc.. The @string refers to the strings.xml file located in the res/values folder. Hence,
@string/hello_world refers to the hello string defined in the strings.xml file, which is "Hello
World!".
50
SECTION 8 – ANDROID CODENAMES, TAGS AND BUILD NUMBERS
Codename Version API level
Android 13 13 33
Android 12 12 32
Android11 11 30
Android10 10 29
Pie 9 28
Oreo 8.1.0 27
Oreo 8.0.0 26
Nougat 7.1 25
Nougat 7.0 24
Marshmallow 6.0 23
Lollipop 5.1 22
Lollipop 5.0 21
KitKat 4.4 - 4.4.4 19
Jelly Bean 4.3.x 18
Jelly Bean 4.2.x 17
Jelly Bean 4.1.x 16
Ice Cream Sandwich 4.0.3 - 4.0.4 15
Ice Cream Sandwich 4.0.1 - 4.0.2 14
51
SECTION 12 – ANDROID AND DATABASE
Read More on Android
1. https://www.tutorialspoint.com/android/index.htm
2. Erik Hellman. Android Programming: Pushing the Limits.1st Edition,Kindle Edition
3. Mark L Murphy (2011) The Busy Coder's Guide to Advanced Android Development
52
propose to a user logged in pharmacies around a geographical
location (specified by the user). Only pharmacies that have
that drug AND that are open AND that are found around that
geographical perimeter should be displayed.
53
TUTORIALS
1)What is Android?
2)What Is the Google Android SDK?
3)What is the Android Architecture?
4)Describe the Android Framework.
5)What is AAPT?
6)What is the importance of having an emulator within the Android environment?
7)What is the use of an activityCreator?
8)What is an activity?
9)Differentiate Activities from Services.
10)What items are important in every Android project?
11)What is the importance of XML-based layouts?
12)What are containers?
13)What is the importance of Android in the mobile market?
14)List and discuss some disadvantages of Android
15)What is adb and what is it used for?
16)What are the four essential states of an activity?
17)What is ANR?
18)What is the importance of settings permissions in app development?
19)What is the function of an intent filter?
20)When is the onStop() method invoked?
21)How can the ANR be prevented?
22)What role does Dalvik play in Android development?
23)What is the AndroidManifest.xml?
24)What is the proper way of setting up an Android-powered device for app
development?
25)What is AIDL?
26)What is a Fragment?
27)What composes a typical Android application project?
28)Do all mobile phones support the latest Android operating system?
29)What language is supported by Android for application development?
30)What are the advantages of hybrid apps over native apps?
54
31)What is Ionic Framework?
32)What is Xamarin?
33)Explain activity lifecycle with the help of a diagram
34)How can data be persisted in an Android app?
35)What is hybrid app development?
36)What is the difference between compileSdkVersion and targetSdkVersion?
37)Describe the process of publishing apps on Google Play and in Apple’s App Store.
What do you need to publish an app to each store?
55