Chapter 1
Architecture and basic features of the Android platform.
1.1 Introduction
Smartphones are extremely sophisticated devices, which provide features in addition to those of conventional
mobile phones such as web browsing, checking and sending emails, voicemail and visual messaging, etc.
Smartphones all run various software and applications thanks to operating systems specially designed for
mobiles. Smartphones can be customized by installing additional applications such as games or utilities through
online application stores (stores).
There are certain constraints for smartphone development and programming, which do not apply to regular
development. At the moment, the RAM memory on phones is limited, which implies that we can launch fewer
programs at once and therefore the software must ensure to reserve less memory. It is also important to consider
that our applications (programs) must be able to interact with a complete system without interrupting it. That is
to say, a certain priority of tasks must be respected, for example the systems allow receiving messages and calls
while using another application. The variation in screen size must be considered again when creating
applications for smartphones.
1.2 Android platform
There are several operating systems specific to smartphones. The most used operating systems are Android,
iOS and Windows Phone.
1.2.1 What is Android?
Android is an open source operating system for smartphones, PDAs and mobile devices.... It is developed by
the world-famous company: Google to integrate Google applications: Gmail, Google Maps, Google Calendar,
YouTube and geolocation..... To mass-market its system, Google federated around Android about thirty
companies (including Sag, Motorola, HTC, Sony Ericsson, LG, ...) within the Open Handset Alliance (OHA).
The aim of OHA is to foster innovation on mobile devices by providing a truly open, comprehensive and free
platform.
The Android SDK (Software Development Kit) provides the tools and APIs (Application Programming
Interface) needed to develop applications on the Android platform using the Java programming language.
4
The Android platform notably offers:
1.2.2 a framework allowing the reuse and replacement of components,
1.2.3 a virtual machine optimized for mobile devices,
1.2.4 an integrated browser based on the open source WebKit engine,
1.2.5 an optimized graphics engine, powered by a dedicated 2D library and a 3D engine based on the
OpenGL ES 1.0 specifications,
1.2.6 the SQLite database management system for data storage,
1.2.7 a media support for the main audio, video and image formats,
1.2.8 GSM telephony, Bluetooth, 3G and WiFi communications,
1.2.9 access to the camera, GPS, compass and accelerometers,
1.2.10 a rich development environment: emulator, debugging tools, ...
The Android Market, renamed Google Play Store in March 2012, allows the download of free or
paid applications. It is also possible to note them and comment on them. At the end of 2010, there
were already more than 100,000 applications on the Android Market, of which only 35.6% were
paid; in September 2011, there were some 520,000 applications on the Google Play Store, of which
still about 65% are free... The increase in the number of applications on the Google Play Store is
exponential! This progression is explained by the completely open development of Android, and
applications can also be distributed otherwise than through it. For
simplify the development of applications, Google has developed a web interface: App Inventor to easily develop
an application that can then be made available on the market.
1.2.2 Origin
Android, which is pronounced Androïd, owes its name to the startup of the same name (specialized in the
development of mobile applications), bought by Google in August 2005. Name which itself comes from "android"
which refers to a robot built in the image of a human being... Based on the Linux kernel, Google’s Android
operating system has widened the gap with Apple in the smartphone sector. Samsung currently remains the
undisputed leader in Android sales, with 73.3 million smartphones sold in three months and 39.1% of market
share.
1.2.3 The versions
The different versions have dessert names (which follow alphabetical order, from A to Z) that are carved and
displayed in front of Google’s headquarters (Mountain View). Where does the dessert name appear on each
version of Android come from? At first, it is a little delirium in the team in charge of the project. The idea is that
5
desserts, like smartphones and tablets, are there to make our lives more enjoyable!!!!!
1.0: Version known to developers: released before the first Android phone (end of 2007).
1.1: Version included in the first phone, the HTC Dream
1.5: Cupcake (Petit Gâteau - Avril 2009), API level 3
1.6: Donut (Beignet - September 2009), API level 4
2.1: Eclair (Eclair - January 2010), API level 7
2.2: FroYo (Frozen Yogurt - May 2010), API level 8
2.3: Gingerbread (Gingerbread - December 2010), API level 9
3.0: Honeycomb (Honey Cake – February 2011), API level 11
3.1: March 2011, API level 12
3.2 : Juillet 2011, API level 13
4.0: Ice Cream Sandwich (October 2011), API level 14
4.0.3 : Décembre 2011, API level 15
4.1: Jelly Bean (Jelly Candy/ Dragée – July 2012), API level 16
4.2 : Octobre 2012, API level 17
4.3 : Juillet 2013, API level 18
4.4: Kitkat, October 2013.
5.0: Lollipop, November 2014.
6.0: Marshmallow at the end of 2015, Nougat, Oreo Then ANDROID 9 Pie,ANDROID10.
1.3 Android architecture
Architecture in 'software stack':
The "Applications" layer: Android is used in a set already containing native applications such as, an
email client, programs to send SMS, calendar, web browser, personal contacts....
The "Application Framework" layer: this layer allows the programmer to build new
applications. This layer provides the management:
des Views (= IHM).
of ContentProviders = accessibility to the data of other applications (e.g. contacts)
and therefore data sharing.
resources = non-coded files such as images, screens (Resource Manager).
of the Notifications (alert display in the title bar).
6
of Activitys = the sequence of screens.
The "Libraries" layer: low software layer to use:
Multimedia formats : images, audio and video.
2D and 3D drawings, bitmap and vector.
Database SQL (SQLite)
The execution environment (Android Runtime): any application is executed in its own process, in its
own Dalvik Virtual Machine. DVM is the Java virtual machine for Android applications, designed to
execute Java code for systems with memory space and execution speed constraints. It executes . dex code
(Dalvik executable) which are . classes adapted to the Android environment. Written by Dan Bornstein,
whose name is an Icelandic village from which some of his ancestors originated. It was chosen by Google
because several instances of the DVM can be launched efficiently. The code of the DVM is open source.
The Linux kernel: on which the Dalvik virtual machine relies to manage multithreading, memory. The
Linux kernel provides security services, process management, etc.
7
Figure 1.1 Architecture in 'software stack'.
8
1. 3.1 The components of an Android application
The fundamental components of an Android application are: Activity, Service, Content Provider, Broadcast
Receiver. Some of these components communicate with each other using Intent:
Activity "manages the display and interaction of a screen": Most applications consist of multiple screens.
Each screen can be achieved by an activity. If a new screen opens, the system uses a story stack to store
previous screens and be able to resume the previous state or remove this state.
Service: A Service is used to create the background application. That is to say, this application can work
when another application is running like music playback services.
Content Provider: Manages shareable data. It is the only way to access data shared between applications.
Content provider example: the contact information of the smartphone user.
Broadcast Receiver: is a component that listens to information intended for it. Such a receiver indicates
the type of information that interests it and for which it will be tapped. Example: incoming phone call,
Wi-Fi network connected, information broadcast by applications.
A receiver is not an IHM but can launch one (possibly small: a notification bar), or can launch a service
processing the arrival of information.
An event (intent) is an "intention" to do something containing information intended for another Android
component. It is an asynchronous message. Activities, services and information receivers use the Intents to
communicate with each other.
9
1.3.2 Life cycle of an activity (Activity Life cycle):
To develop an application on Android, one must understand the life cycle of an activity. The life cycle of an
activity is expressed by the following figure:
- The Active/current state (Running): The activity walks in the foreground.
- Paused state: This activity is visible but not active.
- Stopped status: This activity is not visible. If an activity is completely hidden by another activity, it is stopped
and keeps all the states. However, it is no longer visible to the user, its window is hidden and it will often be
killed by the system when memory is needed elsewhere.
- The Dead state: This activity is over or it has never been started. If an activity is paused or stopped, the system
can delete the activity from memory, either by asking it to end, or simply kill the process. When it is displayed
again to the user, it must be restarted and restored to its previous state.
There are three main loops:
The lifetime of an activity occurs between the first call to OnCreate () and the call to onDestroy (). An
activity sets up all global states in the onCreate() method and releases all remaining resources to
onDestroy().
The visible lifetime of an activity occurs between a call to onStart () and a call corresponding to onStop
(). In this time, the user can see the activity on the screen, even if it is not at the front and the interaction
with the user. Between these two methods, the resources that are needed to show user activity are
conserved.
The lifetime of a foreground activity occurs between a call to onResume () and a call corresponding to
onPause (). In this time, the activity is facing all other activities in order to interact with the user. An
activity can often change its state between the recovery state and the paused state.
10
Figure1.2 Life cycle of an activity.
11
1.3.3 Mobile application
In the field of computer science, an application is a "program written for specific use (calculation,
management, gaming, etc.)". A mobile application is used by means of a mobile electronic device,
such as a Smartphone, tablet, laptop... etc. The mobility and portability of these devices are essential
features of mobile applications. A mobile application is also referred to by the word 'app', whereas
the term 'App' is used in the English-speaking world.
A mobile application can either be installed directly on the device as soon as it is manufactured in
the factory or downloaded from an application store such as Google Play, the App Store or the
Windows Phone Store. Some of the available applications are free while others are paid.
1.3.4 The types of mobile applications
Mobile applications fall into three families:
• Native applications
The software of the native application is developed according to the mobile operating system on
which the application should run (mainly Android and iOS). Due to this development characterized
according to the operating system, the software can quickly interact with the specific tools of the
smartphone: contacts, camera or location. Before it can be used, the native application must be
downloaded by the user on a smartphone or tablet from the application platforms dedicated to the
operating system: Google Play for Android, App Store for iOS. Downloaded and stored directly on
the device, native applications can also draw from their content via an internet connection (dynamic
content) or be completely accessible even in disconnected mode (static content). Although using an
internet connection to be installed and sometimes executed, the native application runs directly on
the support and is not executed by means of the device’s web browser: Google Chrome, Safari,
Firefox, Opera.
• Mobile web applications Also called "web app"
A mobile web application is organized and works around the same three elements with which
websites are built: a client, a server, and a network. From the browser (client) and by means of an
internet connection (network), the smartphone or tablet loads the mobile web application and
interprets the data stored on a remote server. Mobile web applications have been developed in
parallel with the evolution of smartphones and native apps. Website developers faced two major
difficulties: from screens to
9
different dimensions and the multiplicity of devices supporting internet browsing. The consultation
of a website on a smartphone screen was often only possible by using the device’s zoom function, as
websites were not specifically developed to adapt to navigation on small screens.
As technology evolves, developers have succeeded in creating websites whose content "recognizes"
the characteristics of the client device. The site automatically adapts its content to be viewed on a
computer or smartphone screen. HTML and CSS languages are mainly at the origin of the
development of mobile web applications. The expression used is "responsive website", or, more
and more commonly, "responsive web design" according to English terminology.
Hybrid applications
The hybrid application combines two different components to offer a new whole. It works like a
native application, using the specific tools already available on the smartphone or tablet and, on the
other hand, thanks to the HTML language and CSS style attributes, it leverages the features of
adaptive websites used in mobile web applications. Like native applications, hybrid applications
are downloaded from the usual app platforms.
1.3.5 Mobile Operating System
Dozens of operating systems (OS) exist on the market: Nokia's Symbian OS, Apple's iOS, RIM's
BlackBerry OS, Microsoft's Windows Phone, Samsung's Bada, and Google's Android, etc.
Symbian OS
The Symbian OS is developed by the eponymous company, which is exclusively owned by Nokia.
Although this platform was created with the participation of several manufacturers such as
Samsung or Sony Ericsson, the system is strongly associated with Nokia, which has hindered its
adoption by other manufacturers. It was recently made open source. It is a free, open-source system
based on a Symbian kernel.
iOS
iOS (Internetwork Operating System), formerly called iPhone OS, is found not only on the
different generations of the iPhone but also on other Apple products. It is derived from Mac OS,
with which it shares the foundations: the kernel, Unix services, and Cocoa. For Apple, the success
has been considerable: at the beginning of 2009, there were no fewer than 5 million downloads
per day. Therefore, it is Android’s number one competitor.
10
BlackBerry OS
The BlackBerry operating system is the exclusive mobile platform developed by RIM (Research
In Motion) solely for its BlackBerry smartphones and mobile devices. RIM uses this operating
system to support specialized functions, notably the brand’s trackball, scroll wheel, trackpad, and
touchscreen.
Windows Phone
Windows Mobile is Microsoft’s mobile operating system. Over the years, this OS has managed to
secure a respectable market share. Its success is due to its affiliation with the Windows family of
operating systems, which is overwhelmingly dominant on the desktop. Another often-cited
advantage is the ease of development provided by the Visual Studio point-and-click environment,
which succeeded in bringing VB (Visual Basic) developers into mobile development.
Android
Android was initially developed by a small startup and later acquired by Google, which continues
to actively develop and distribute it under an open-source license. Google launched the Open
Handset Alliance, bringing together major manufacturers and software developers (such as Intel,
HTC, ARM, Samsung, Motorola). This system has achieved the largest market share and user
base. It has several versions, each with a specific name.
1.4 Conclusion
In this chapter, we introduced mobile applications as well as mobile operating systems. In the
following chapter, we focus on Google’s famous Android operating system.
11
Chapter 2
The Android Platform
2.1 Introduction
Smartphones are extremely sophisticated devices that provide functionalities beyond those of traditional mobile
phones, such as web browsing, reading and sending emails, voicemail and visual messaging, etc. Smartphones
run various software and applications thanks to operating systems specifically designed for mobile devices. They
can also be customized by installing additional applications such as games or utilities through online application
stores.
There are certain constraints in smartphone development and programming that do not apply to conventional
development. At present, RAM on phones is limited, which means fewer programs can be run simultaneously;
therefore, software must be designed to reserve less memory. It is also important to consider that applications
must be able to interact with a complete system without interrupting it. In other words, a certain task priority must
be respected — for example, systems must allow receiving messages and calls while another application is
running. Screen size variation must also be taken into account when developing smartphone applications.
There are several operating systems specific to smartphones, with the most widely used being Android, iOS, and
Windows Phone. In this chapter, we focus on Android.
2.2 The Android Platform
2.2.1 What is Android?
Android is an open-source operating system for smartphones, PDAs, and mobile terminals. It is developed by
the globally known company Google to integrate Google applications such as Gmail, Google Maps, Google
Calendar, YouTube, and geolocation services.
To widely distribute its system, Google brought together around thirty companies (including Sag, Motorola,
HTC, Sony Ericsson, LG, etc.) within the Open Handset Alliance (OHA). The goal of the OHA is to promote
innovation on mobile devices by providing a truly open, complete, and free platform.
The Android SDK (Software Development Kit) provides the tools and APIs (Application Programming
Interfaces) needed to develop applications on the Android platform using the Java programming language.
The Android platform notably offers:
12
A framework allowing the reuse and replacement of components,
A virtual machine optimized for mobile devices,
An integrated browser based on the open-source WebKit engine,
An optimized graphics engine, powered by a dedicated 2D library and a 3D engine based on the
OpenGL ES 1.0 specifications,
The SQLite database management system for data storage,
Media support for major audio, video, and image formats,
GSM telephony, Bluetooth, 4G, and WiFi communications,
Access to the camera, GPS, compass, and accelerometers,
A rich development environment: emulator, debugging tools
The Android Market, renamed Google Play Store in March 2012, allows the
downloading of free or paid applications. It is also possible to rate and review them.
By the end of 2010, there were already more than 100,000 applications on the
Android Market, of which only 35.6% were paid; by September 2011, the Google
Play Store counted around 520,000 applications, with still about 65% being free…
The growth in the number of applications on the Google Play Store is exponential!
This increase can be explained by the fully open development of Android, and
applications can also be distributed through means other than the Play Store. To
simplify application development, Google created a web interface: App Inventor,
which makes it easy to develop an application that can then be made available on
the market.
Android, pronounced Androïd, takes its name from the startup of the same name
(specialized in mobile application development), acquired by Google in August
2005. The name itself comes from 'android,' which refers to a robot built in the
likeness of a human being. Based on the Linux kernel, Google’s Android operating
system has widened the gap with Apple in the smartphone sector. Samsung currently
remains the undisputed leader in Android sales, with 73.3 million smartphones sold
in three months and a 39.1% market share.
13
2.3 Les composants d'une application Android
The fundamental components of an Android application are the following: Activity, Service, Content
Provider, and Broadcast Receiver. These components can communicate with each other using Intents:
Activity: manages the display and interaction with a screen. Most applications are composed of several
screens, each of which can be implemented by an activity. When a new screen is opened, Android uses a
history stack to store the state of the previous screens and allow their restoration.
Service: a service executes tasks in the background, even if the user is interacting with another
application. Example: a music playback service that continues running even if the user opens a different
application.
Content Provider: manages and shares data between applications. It is the only mechanism that allows
access to shared data, such as contacts stored on the phone.
Broadcast Receiver: listens for events or information broadcast by the system or other applications.
Example: receiving an incoming call, connecting to a Wi-Fi network, or receiving notifications from
applications. The receiver does not have its own user interface but can trigger a notification or start a
service in response to the event.
Finally, components communicate through Intents, which are asynchronous messages used to transmit
information or trigger an action in another Android component.
2.4 Developing an Android Application
Mobile application development requires considering several hardware and efficiency constraints:
Hardware constraints:
1. Limited processor power;
2. Restricted RAM memory;
3. Small screens with low resolution;
4. Sometimes unstable network connections.
Efficiency: the code must be optimized to ensure speed and responsiveness.
Phases of Android application development:
1. Installation of the development environment (setup);
2. Writing the application code and resources;
3. Debugging and testing;
14
4. Publishing on the Google Play Store.
Environments and necessary tools:
Option 1:
o JDK (Java Development Kit) – for compiling Java code;
o Eclipse + ADT (Android Development Tools) – IDE for Java with the Android plugin;
o Android SDK (Software Development Kit) – for compiling and running on the emulator.
Option 2 (recommended):
o JDK + Android Studio (the official IDE for Android).
2.5 The Android SDK
Android development is possible on Linux, Windows, and MacOS. Two environments are commonly used:
Eclipse with the ADT plugin;
Android Studio (the official solution).
Both tools are based on the Android SDK, which contains:
The Java libraries specific to Android;
Development tools (compilation, debugging);
An emulator to test applications;
Android system images.
📌 Notes:
If you use Android Studio, it is not necessary to download the SDK separately, as it is integrated.
The SDK includes a manager (SDK Manager) that allows installing and updating the necessary
components.
To run an application on a computer, you must create an Android Virtual Machine via the AVD
(Android Virtual Device) Manager
15
Figure 2.1. L’AVD manager.
The emulator (Figure 2.3) allows you to test your application :
Figure 2.2. Android Emulator
2.6 Conclusion
In this chapter, we presented the architecture and basic functionalities of the Android platform as
well as the different components of an application. In the next chapter, we will detail the main
component, Activity, along with the various resources used by an Android application.
16