0% found this document useful (0 votes)
10 views

Programming of Mobile Terminals

The document outlines a course on mobile application development, focusing on both Android and iOS operating systems. It covers various topics including mobile technologies, application security, and practical exercises in mobile programming. The course aims to equip students with skills in mobile UI design, API integration, and development using Android Studio and Java.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Programming of Mobile Terminals

The document outlines a course on mobile application development, focusing on both Android and iOS operating systems. It covers various topics including mobile technologies, application security, and practical exercises in mobile programming. The course aims to equip students with skills in mobile UI design, API integration, and development using Android Studio and Java.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

One

Step
At A
Time

HND 2025
PROGRAMMING OF MOBILE TERMINAL
Detailed Lesson notes with practical exercises and applications in Mobile Application
Programming.

Version 2.6 January 2025


Objectives
This course offers an introduction to mobile application development and application security.
Toward this goal students will learn how to:
- Specify the generalities of mobile technologies
- Understand the functioning of the Android Operating System
- Be able to differentiate the various mobile development technologies.
- Security requirements for a mobile application
- Vulnerability assessment of a mobile system
- Security patches and updates.
- Understand and be able to differentiate the various iOS and Android OS versions.
- Install and configure the Android Studio IDE
- Mastering the Gradle and AndroidManifest files.
- Design mobile UIs using diverse technologies.
- Develop basic applications for the Android OS.
- Develop mobile applications that can perform API calls.

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

SECTION 1 – GENERALITIES OF MOBILE TERMINALS

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.

1.2 Types of Mobile Computing Devices


The term mobile device refers to a wide range of consumer electronics. Mobile device
typically is used to describe portable devices that can connect to the Internet. However, some
also classify connected digital cameras and standard MP3 players as mobile devices as well.
The category of mobile devices includes the following devices, as well as others:
A) Personal Digital Assistant (PDA)
The name of PDA is Pocket computer; this device is capable to
transmit data from one terminal to other terminal with
synchronization. In the PDA have all functionality such as making
call voice/video, calendar, and more. Today, PDAs are available in

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.

Mobile Operating Systems (Mobile OS)


Like a computer operating system, a mobile operating system is the software platform for
mobile devices on top of which other programs run. When you purchase a mobile device, the
manufacturer will have chosen the mobile OS for that specific device. The mobile operating
system is responsible for determining the functions and features available on your device,
such as thumbwheel, keyboards, LTE, GPRS, synchronization with applications, e-mail, text
messaging and more.
The mobile operating system will also determine which third-party applications can be used
on your device. Some of the more common and well-known mobile operating systems include
the following:

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.

iii) Windows Phone


Originally called the Windows Mobile platform and then Windows Phone, Microsoft’s
mobile OS is available on a variety of devices from a variety of wireless operators. You will
find Windows Phone on Microsoft hardware devices as well as Nokia, Dell, HP, Motorola,
Palm and i-mate products. Microsoft unveiled the latest release of its mobile operating
system, Windows 10 Mobile, in late 2015 as part of the Windows 10 family of operating
systems.

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.

1.3 Mobile Computing - Major Advantages


Mobile computing has changed the complete landscape of our day-to-day life. Following are
the major advantages of Mobile Computing –

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

2.2 Features of the Android Operating System


All the android applications are at the top layer and are installed on this layer. Examples of
such applications are contacts, books, browsers, services, etc. Each application performs a
different role in the overall applications.
Features:
 Headset layout
 Storage
 Connectivity: GSM/EDGE, IDEN, CDMA, Bluetooth, WI-FI, EDGE,3G, NFC,
LTE,GPS.
 Messaging: SMS, MMS, C2DM (could to device messaging), GCM (Google could
messaging)
 Multilanguage support
 Multi-touch
 Video calling
 Screen capture
 External storage
 Streaming media support
 Optimized graphics

2.3 Android Architecture:


The android is an operating system and is a stack of software components which is divided
into five sections and four main layers that is
 Linux kernel
 Libraries
 Android runtime
Application framework:

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.

2.3.4 Application framework:


The application framework layer provides many higher-level services to applications such as
windows manager, view system, package manager, resource manager, etc. The application
developers are allowed to make use of these services in their application.

2.3.5 Android Emulator:


The Emulator is a new application in the Android operating system. The emulator is a new
prototype that is used to develop and test android applications without using any physical
device.

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.

Advantages of the Android OS:


 Android is a Linux based open-source operating system, it can be developed by
anyone
 Easy access to android apps
 You can replace the battery and mass storage, disk drive and UDB option
 Its supports all Google services
 The operating system is able to inform you of a new SMS and Emails or latest
updates.
 It supports Multitasking
 Android phone can also function as a router to share internet
 It’s free to customize
 Can install a modified ROM through rooting.
 Its supports 2D and 3D graphics

2.4 Security and Privacy


Android as an operating system is very secure. It has multiple layers of protection to keep
malware at bay, and it requires your specific permission to do almost anything that could lead
to your data or the system being compromised. Mobile security apps are applications designed
for smartphone and tablet mobile devices to protect and secure the device and its data from
unauthorized access in the case of theft or accidental loss. Some mobile security apps can also
help users locate their device if it s lost or stolen.
Additional security features frequently offered by Android mobile security apps include
securing data on the device, VPN connectivity for protecting data in transit, scanning websites
for potential phishing schemes or other fraudulent activity, helping users locate their device if
lost or stolen, and more.

2.5 Mobile Security Threats


Mobile security threats include both physical and software-based threats that can compromise
the data on smartphones, tablets and similar mobile devices. Mobile security threats include
everything from mobile forms of malware and spyware to the potential for unauthorized
access to a device s data, particularly in the case of accidental loss or theft of the device.

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.

2.5.1 Physical Mobile Security Threats and Other Types of Threats


When it comes to physical mobile security threats, phones that lack passwords, screen locks
or other forms of authentication are vulnerable to unauthorized access, which can compromise
sensitive information stored on the mobile device. And if the device gets lost or stolen,
hackers can bypass many forms of authentication in order to gain access to the device s
sensitive information.
Additional types of mobile security threats include applications that take advantage of
vulnerabilities in the mobile operating system or a mobile application to gain access and/or
control of the device, phishing scams, Web browser and network-based exploits, Wi-Fi packet
sniffing for accessing mobile device data

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.

3.2 Features of the iOS System


The power of iOS can be felt with some of the following features provided as a part of the
device:
Maps, Siri, Facebook and Twitter, Multi-Touch, Accelerometer, GPS, High end processor,
Camera, Safari, Powerful APIs, Game center, In-App Purchase, Reminders, Wide Range of
gestures

3.3 Hardware Platform of the iOS System


The main hardware platform for iOS is the ARM architecture and is 64-bit only. It includes a
native 64-bit kernel, libraries, drivers as well as all built-in applications.

3.4 Development Platform of the iOS System


The iOS SDK (XCode) allows for the development of mobile apps on iOS.
While originally developing iPhone prior to its unveiling in 2007, Apple's then-CEO Steve
Jobs did not intend to let third-party developers build native apps for iOS, instead directing
them to make web applications for the Safari web browser. However, backlash from
developers prompted the company to reconsider, with Jobs announcing in October 2007 that
Apple would have a software development kit available for developers by February 2008. The
SDK was released on March 6, 2008.

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

3.5 Security and Privacy


Precise location controls: Apple’s iOS 16 comes with technology that allows you to give
apps your approximate location, without revealing exactly where you are.

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.

SECTION 4 – WEB APPLICATIONS FOR MOBILE PLATFORMS


A web application is application software that runs on a web server, unlike computer-based
software programs that are run locally on the operating system of the device. Web
applications are accessed by the user through a web browser with an active internet
connection.

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.

4.1 Differences between Web, Native and Cross-Platform Apps


Native apps are a great way to create a powerful and responsive product. Web apps are good
for simple projects when you just need to get the job done. Cross-platform apps are something
in between: good for some things, terrible for others. Hybrid mobile apps are applications that
are installed on a device, just like any other app. Hybrid apps are deployed in a native
container that uses a mobile WebView object. When the app is used, this object displays web
content thanks to the use of web technologies (CSS, JavaScript, HTML, HTML5).

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.

4.1.1 Native applications


Native applications are tailored to a specific mobile platform (Android or iOS). Typically,
users get them from app stores. Native iOS apps are coded in Swift or Objective-C, whereas
Native Android apps are written in Java or Kotlin. Examples of Native apps include

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.

4.1.2 Web applications


Web applications are developed as websites using a combination of HTML5 and JavaScript.
These websites are later wrapped in an invisible native WebView container. Some are built
using technologies like Cordova and PhoneGap.

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.

4.1.3 Cross-platform applications


Cross-platform apps are easier to develop than native apps, and parts of their code can be
shared across platforms. The advantage of cross-platform applications over web apps is that
they have direct contact with the mobile operating system. They’re usually developed with
Xamarin, Xcode,React Native, Appcelerator, NativeScript etc. However, direct access to the
operating system doesn’t mean full command of everything it has to offer.

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.

High-performance UI/UX. In cross-platform development, the UI and UX are rendered with


native controls. This means that it’s easier to achieve design performance very close to that of
a native app.

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.

Example of a cross-platform application: Airbnb (React Native), Facebook Ads Manager is a


great example of a cross-platform application.
Conclusions
It is quite easy to make a choice, it just depend on the aims you are going to reach and the
functionality to empower your mobile application. If the work of your application requires the
devices which maintain a large amount of functionality or information processing rate is very
important (games, social networks, geolocation services, photos exchange services, etc.) you
need to make a native application. If the work speed is not that important, and user needs to
get only information with the mobile Internet, you can absolutely come up with web
application. Web applications should also be used as prototypes to estimate users’ reaction on
your idea and get a certain feedback. This web characteristic is similar to cross-platform
applications. If your interface is not provided for complicated animation and does not perform
calculations, you need to quickly enter the market to test your idea, if you are ready to put up
with interface problems and so on, - cross-platform application will do.

4.2 Tools for building web applications


Web apps tend to be built using JavaScript, CSS3 and HTML5. Unlike mobile apps, there is
no standard software development kit for building web apps. However, developers do have
access to templates. Compared to mobile apps, web apps are usually quicker and easier to
build — but they are much simpler in terms of features.

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.

5.1 Some Mobile App Development Frameworks


1. Swiftic
Swiftic is one of the best mobile app development frameworks available in the iOS platform.
It is featured with an easily navigable interface. It can be accessed from HERE.
Some of the significant features are:
 Interesting push notification
 Become a loyal shopper with a loyalty card
 Build your mobile store
 In-app coupons
 Use scratch cards to win prizes
 Easy Communication
 Menu & Ordering
 Customer Engagement
 App Promotion
 Social & Media Feeds
 App Publication Assistance
 Advanced Analytics
 Third-party integration

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.

Some of the Ionic features are:

 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.

Some of the Mobile Angular UI features are:

 Build HTML5 hybrid desktop & mobile apps


 No jQuery dependencies
 Build fully responsive interfaces with a super-small CSS file

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:

 Built-in material design


 Built-in Cupertino (iOS-flavor) widgets
 Rich motion APIs
 Supports both iOS & Android
 Strong widget support
 High-performance application

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.

6.1 Prerequisites of Android Programming


1. Basic Knowledge About Programming
To learn any technology, one has to know about programming means one has to know about
what is functions or methods, what is variables and how to use them to get a fruitful result,
and some little bit about data structures like arrays, linked lists, etc.

2. Learn Java or Kotlin


To develop an android app you have to write code in Java or Kotlin. You have to learn any of
these languages to communicate with android studio and make an app. Without Java or
Kotlin, it’s not possible to make an android app. Both languages are Object-Oriented
Programming Language.

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.

3. Recall: Concepts of OOPs (Object Oriented Programming)


OOP concepts are the concepts of objects. Making an android app is so easy but making a
real-world app with android is not only make an app it’s many more. When you come to
know about the core concepts of android, you have to understand those concepts properly. For
learning those core concepts you first need to OOP concepts. In OOP, there are 4 main
concepts means you have to learn. Refer to your notes in JAVA.

1. Encapsulation: Encapsulation is a way of wrapping up the data in a single unit and


prevent the data accessed outside of the wrap.
2. Abstraction: Abstraction is a way to hide nonessential information and show only
essential ones.
3. Inheritance: As you can see its name it’s a way to inherit the properties of other
classes. With that, you can use all features of a class to build other classes.
4. Polymorphism: As polymorphism means it can uses classes and perform them in
different ways. With that, an inherited class can act in different ways.

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.

b) Android SDK/Android Studio/Eclipse

Next comes Android SDK. It contains libraries, debugger, an emulator, documentations,


sample codes and tutorials for each of the released versions of Android.
Note: Before the release of Android Studio, SDK was a standalone part of the Android
Application development tools that could be integrated with other IDE's like Eclipse with the
help of Android ADT Bundle. Later on, Google made Android SDK as a part of the Android
Studio, which is the official IDE for Android development.

You can download the complete Android Development Environment bundle(Android Studio
+ SDK) from the link here.

c) Setup and Installation of Android Studio

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.

6.3 SDK MANAGER


The Android SDK Manager, manages various Android SDK versions, tools and various
other useful packages that you can select and download, to keep your development
environment up-to-date.

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".

6.4 Creating Android Virtual Device with AVD Manager


We will learn what is AVD Manager and how you can we create an AVD (Android Virtual
Device) to test your first android application. An Android Virtual Device (AVD) is a device
configuration that runs on the Android Emulator. It provides virtual device-specific Android
Environment in which we can install & test our Android Application. AVD Manager is a part
of SDK Manager to create and manage the virtual devices created.

To open AVD manager, go to Tools → Android → AVD Manager as shown in below


image.

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.

6.5 Android - Application Components


Application components are the essential building blocks of an Android application. These
components are loosely coupled by the application manifest file AndroidManifest.xml that
describes each component of the application and how they interact.

There are following four main components that can be used within an Android application −

Sr.No Components & Description


1 Activities

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.

An activity is implemented as a subclass of Activity class as follows −


public class MainActivity extends Activity {
}
Services
A service is a component that runs in the background to perform long-running operations. For
example, a service might play music in the background while the user is in a different
application, or it might fetch data over the network without blocking user interaction with an
activity.

A service is implemented as a subclass of Service class as follows −


public class MyService extends Service {
}

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.

A broadcast receiver is implemented as a subclass of BroadcastReceiver class and each


message is broadcaster as an Intent object.

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.

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.

public class MyContentProvider extends ContentProvider {


public void onCreate(){}
}

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.

7.1 App Basics


Our first application will be a simple application with one activity and a layout, in which we
will just print Hello World! on the device screen. Here are a few things that you must know,
don't worry about it, you will understand all these, as we move forward:

 An activity is an instance of Activity, a class in the Android SDK. An activity is


responsible for managing user interaction with a screen of information. Whenever we
create a new activity, we are actually writing a subclass of Activity class. A simple
application may need only one subclass, while a complex application can have many.
In our first application FirstAppActivity will be our activity subclass.
 A layout defines a set of user interface(UI) objects(Views and Widgets) and their
position on the device screen. A layout is made up of definitions written in XML.
Each definition is used to create an object(a user interface) that appears on the device's
screen, like a button or some text or an image.

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.

7.2 Hello World! Android Application


The first step is to create a simple Android Application using Android studio. When you click
on Android studio icon, it will show screen as shown below

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

This is an auto generated file which contains compileSdkVersion,


buildToolsVersion, applicationId, minSdkVersion, targetSdkVersion, versionCode
and versionName

Following section will give a brief overview of the important application files.

7.4 The Main Activity File

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;

public class MainActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Here, R.layout.activity_main refers to the activity_main.xml file located in the res/layout


folder. The onCreate() method is one of many methods that are figured when an activity is
loaded.

7.5 The Manifest File


Whatever component you develop as a part of your application, you must declare all its
components in a manifest.xml which resides at the root of the application project directory.
This file works as an interface between Android OS and your application, so if you do not

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>

Here <application>...</application> tags enclosed the components related to the application.


Attribute android:icon will point to the application icon available under res/drawable-hdpi.
The application uses the image named ic_launcher.png located in the drawable folders

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

7.6 The Strings File


The strings.xml file is located in the res/values folder and it contains all the text that your
application uses. For example, the names of buttons, labels, default text, and similar types of
strings go into this file. This file is responsible for their textual content. For example, a default
strings file will look like as following file −
<resources>
<string name="app_name">HelloWorld</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
</resources>

7.7 The Layout File


The activity_main.xml is a layout file available in res/layout directory, that is referenced by
your application when building its interface. You will modify this file very frequently to
change the layout of your application. For your "Hello World!" application, this file will have
following content related to default layout −

<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!".

7.8 Running the Application


Let's try to run our Hello World! application we just created. I assume you had created your
AVD while doing environment set-up. To run the app from Android studio, open one of your
project's activity files and click Run icon from the tool bar. Android studio installs the app
on your AVD and starts it and if everything is fine with your set-up and application, it will
display following Emulator window −

Congratulations!!! you have developed


your first Android Application and now
just keep following rest of the tutorial
step by step to become a great Android
Developer. All the very best.

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

SECTION 9 – ANDROID LAYOUTS AND HOW TO USE THEM


 Linear Layout
 Relative Layout
 Table Layout
 Absolute Layout
 List Layout
 Grid Layout
 Frame Layouts

SECTION 10 – ANDROID CONTROLS AND EVENT HANDLERS


 Buttons
 TextViews
 EditText
 ImageButton
 CheckBox
 Spinner
 RadioButton
 Creating UI controls
 onclick() events
 onTouch() events
 onFocuChange() events
SECTION 11 – ANDROID WITH PHP AS API
 How to use PHP as an API to communicate with the server.
Check the source code sent along with the notes for better understanding.

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

SECTION 14 – OTHER ANDROID PROJECTS


No PROJECT TITLE PROJECT DESCRIPTION
.
1 Hello App ! This app takes a user’s name and displays in on a Toast, same
activity and on a button.
2 Simple Calculator Has 2 TextViews and accepts 2 numbers and performs a
selected operation and displays the answer on a Toast.
3 Simple Form This app should be able to perform all calculator basic
functions (BODMAS).
4 Unit Converter This application should be able to convert the following units:
cm-m, g-kg, cl-l
5 Countdown and The app should be able to launch a countdown and stopwatch
Stopwatch based on what the user wants. It should have a home page and
2 buttons (countdown and stopwatch) which opens when the
user clicks on.
6 Google Map The app should have a button that when you click on it, it
opens Google map in the app and shows your current location.
The user can click on another button GET COORDINATES to
return the current coordinates.
7 Camera, Storage The app should be able to take a photo with your camera and
and Upload save in your phone. The App should have a SHARE button
that can also share the image to another app.
8 Database 1 This app should be able to register a user using name, email,
date of birth, telephone, photo, region of origin, sex and saves
the information into a database.
9 Android CRUD Create any App of your choice that perform CRUD
operations. The app MUST have the following: tables, lists,
spinner, menus, tables, progress bar, date picker. This login
section should pass a user’s name as parameter to all the other
activities and the user’s name can be displayed on the top of
ALL the other activities.
10 Web App + Push The admin can send a message from the web application and
Notification the message is saved in the database and appears as a Push
Notification on the Android App.
11 AI Project Using sightengine, develop an android app that permits a user
to upload a photo and determine if that photo is appropriate or
not for social media consumption.
12 AI Project 2 Using the model you trained in the course ARTIFICIAL
INTELLIGENCE, develop a mobile app that logins the user
that was registered.
13 Pharmacy On Call Develop a mobile app that gets a drug as parameter and

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?

COURAGE AND GOODLUCK MY FUTURE


ENGINEERS

55

You might also like