11.intro Andr

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Android Operating System

Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Ranjit Patnaik Introduction to Android Operating System 1 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Content

1 Android Operating System

2 Android Architecture

3 Android Core Building Blocks

4 Android Emulator

5 The Activity Lifecycle

6 Lifecycle callbacks

Ranjit Patnaik Introduction to Android Operating System 2 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Android Operating System

Android is described as a mobile operating system, initially developed by


Android Inc. Android was sold to Google in 2005. Android is based on a
modied Linux 2.6 kernel. Google, as well as other members of the Open
Handset Alliance (OHA) collaborated on Android (design, development,
distribution). Currently, the Android Open Source Project (AOSP) is
governing the Android maintenance and development cycle
An open platform for mobile development
A hardware reference design for mobile devices
A system powered by a modied Linux 2.6 kernel
A run time environment
An application and user interface (UI) framework

Ranjit Patnaik Introduction to Android Operating System 3 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Android Architecture

Figure 1 outlines the current (layered) Android Architecture. The modied


Linux kernel operates as the HAL, and provides device driver, memory
management, process management, as well as networking functionalities,
respectively. The library layer is interfaced through Java (which deviates
from the traditional Linux design). It is in this layer that the Android
specic libc(Bionic) is located. The surface manager handles the user
interface (UI) windows. The Android runtime layer holds the Dalvik Virtual
Machine (DVM) and the core libraries (such as Java or IO). Most of the
functionalities available in Android are provided via the core libraries.

Ranjit Patnaik Introduction to Android Operating System 4 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Continue....

Ranjit Patnaik Introduction to Android Operating System 5 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Continue....

The application framework houses the API interface. In this layer, the
activity manager governs the application life cycle. The content providers
enable applications to either access data from other applications or to share
their own data. The resource manager provides access to non-code
resources (such as graphics), while the notication manager enables
applications to display custom alerts. On top of the application framework
are the built-in, as well as the user applications, respectively. It has to be
pointed out that a user application can replace a built-in application, and
that each Android application runs in its own process space, within its own
DVM instance. Most of these major Android components are further
discussed (in more detail) in the next few sections of this report.

Ranjit Patnaik Introduction to Android Operating System 6 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

content...

The main components of android architecture are following:-


1 Applications
2 Application Framework
3 Android Runtime
4 Platform Libraries
5 Linux Kernel

Ranjit Patnaik Introduction to Android Operating System 7 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Application

Applications  Applications is the top layer of android architecture. The


pre-installed applications like home, contacts, camera, gallery etc and third
party applications downloaded from the play store like chat applications,
games etc. will be installed on this layer only. It runs within the Android
run time with the help of the classes and services provided by the
application framework.

Ranjit Patnaik Introduction to Android Operating System 8 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Application framework

Application framework  Application Framework provides several important


classes which are used to create an Android application. It provides a
generic abstraction for hardware access and also helps in managing the user
interface with application resources. Generally, it provides the services with
the help of which we can create a particular class and make that class
helpful for the Applications creation.
It includes dierent types of services activity manager, notication
manager, view system, package manager etc. which are helpful for the
development of our application according to the prerequisite.

Ranjit Patnaik Introduction to Android Operating System 9 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Application runtime

Application runtime  Android Runtime environment is one of the most


important part of Android. It contains components like core libraries and
the Dalvik virtual machine(DVM). Mainly, it provides the base for the
application framework and powers our application with the help of the core
libraries.
Like Java Virtual Machine (JVM), Dalvik Virtual Machine (DVM) is a
register-based virtual machine and specially designed and optimized for
android to ensure that a device can run multiple instances eciently. It
depends on the layer Linux kernel for threading and low-level memory
management. The core libraries enable us to implement android
applications using the standard JAVA or Kotlin programming languages.

Ranjit Patnaik Introduction to Android Operating System 10 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Platform libraries

Platform libraries  The Platform Libraries includes various C/C++ core


libraries and Java based libraries such as Media, Graphics, Surface
Manager, OpenGL etc. to provide a support for android development.
Media library provides support to play and record an audio and video
formats. Surface manager responsible for managing access to the display
subsystem. SGL and OpenGL both cross-language, cross-platform
application program interface (API) are used for 2D and 3D computer
graphics. SQLite provides database support and FreeType provides font
support. Web-Kit This open source web browser engine provides all the
functionality to display web content and to simplify page loading. SSL
(Secure Sockets Layer) is security technology to establish an encrypted link
between a web server and a web browser.

Ranjit Patnaik Introduction to Android Operating System 11 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Linux Kernel

Linux Kernel  Linux Kernel is heart of the android architecture. It


manages all the available drivers such as display drivers, camera drivers,
Bluetooth drivers, audio drivers, memory drivers, etc. which are required
during the runtime.
The Linux Kernel will provide an abstraction layer between the device
hardware and the other components of android architecture. It is
responsible for management of memory, power, devices etc.

Ranjit Patnaik Introduction to Android Operating System 12 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

The features of Linux kernel are

Security: The Linux kernel handles the security between the application
and the system. Memory Management: It eciently handles the memory
management thereby providing the freedom to develop our apps. Process
Management: It manages the process well, allocates resources to processes
whenever they need them. Network Stack: It eectively handles the
network communication. Driver Model: It ensures that the application
works properly on the device and hardware manufacturers responsible for
building their drivers into the Linux build.

Ranjit Patnaik Introduction to Android Operating System 13 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Android Core Building Blocks

An android component is simply a piece of code that has a well dened life
cycle e.g. Activity, Receiver, Service etc.
The core building blocks or fundamental components of android are
activities, views, intents, services, content providers, fragments and
AndroidManifest.xml.
Activity:
Being similar to a Frame in AWT, an activity as a class represents a
single screen. It is a core building block, i.e., the fundamental
component of android.
View: The UI element including button, label, text eld, etc, and
anything that one can see is a view.

Ranjit Patnaik Introduction to Android Operating System 14 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Continue....

Intent: Along with invoking the components, the Intent is used for many
purposes including:
Start the service
Launch an activity
Display a web page
Display a list of contacts
Broadcast a message
Dial a phone call etc.

Ranjit Patnaik Introduction to Android Operating System 15 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Continue....

Service: Being a background process the service can run for a long
time.
The local and remote are the two types of services. Within the
application, the local service is accessed. While from other
applications running on the same device the remote service can be
accessed remotely.
Content Provider: To share the data between the applications, the
Content Providers are used.
Fragment: Being a part of an activity, one or more fragments can be
displayed on the screen at the same time by the activity.

Ranjit Patnaik Introduction to Android Operating System 16 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Continue....

AndroidManifest.xml: Information about activities, content providers,


permissions, etc is in the AndroidManifest.xml which is like the web.xml le
in Java EE.
Android Virtual Device (AVD): To test an android application without
using a mobile or a tablet, the Android Virtual Device or AVD is used. To
emulate dierent types of real devices, an AVD can be created in dierent
congurations.

Ranjit Patnaik Introduction to Android Operating System 17 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Android Versions, Codename and API

Version Code name API Level


1.5 Cupcake 3
1.6 Donut 4
2.1 Eclair 7
2.2 Froyo 8
2.3 Gingerbread 9 and 10
3.1 and 3.3 Honeycomb 12 and 13
4.0 Ice Cream Sandwitch 15
4.1, 4.2 and 4.3 Jelly Bean 16, 17 and 18
4.4 KitKat 19
5.0 Lollipop 21
6.0 Marshmallow 23
7.0 Nougat 24-25
8.0 Oreo 26-27
9.0 Pie 27
10.0 Android Q 29
11.0 Android 11 30
Ranjit Patnaik Introduction to Android Operating System 18 / 28
Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Android Emulator

The Android emulator is an Android Virtual Device (AVD), which


represents a specic Android device. We can use the Android emulator as a
target device to execute and test our Android application on our PC. The
Android emulator provides almost all the functionality of a real device. We
can get the incoming phone calls and text messages. It also gives the
location of the device and simulates dierent network speeds. Android
emulator simulates rotation and other hardware sensors. It accesses the
Google Play store, and much more.

Ranjit Patnaik Introduction to Android Operating System 19 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Continue....

Testing Android applications on


emulator are sometimes faster and
easier than doing on a real device.
For example, we can transfer data
faster to the emulator than to a real
device connected through USB.
The Android emulator comes with
predened congurations for several
Android phones, Wear OS, tablet,
Android TV devices.

Ranjit Patnaik Introduction to Android Operating System 20 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

The Activity Lifecycle

Ranjit Patnaik Introduction to Android Operating System 21 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Continue....

To navigate transitions between stages of the activity lifecycle, the Activity


class provides a core set of six callbacks: onCreate(), onStart(),
onResume(), onPause(), onStop(), and onDestroy(). The system
invokes each of these callbacks as an activity enters a new state.
Figure above presents a visual representation of this paradigm.

Ranjit Patnaik Introduction to Android Operating System 22 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Lifecycle callbacks

This section provides conceptual and implementation information about the


callback methods used during the activity lifecycle.

Ranjit Patnaik Introduction to Android Operating System 23 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

onCreate()

You must implement this callback, which res when the system rst creates
the activity. On activity creation, the activity enters the Created state. In
the onCreate() method, you perform basic application startup logic that
should happen only once for the entire life of the activity. For example,
your implementation of onCreate() might bind data to lists, associate the
activity with a ViewModel, and instantiate some class-scope variables. This
method receives the parameter savedInstanceState, which is a Bundle
object containing the activity's previously saved state. If the activity has
never existed before, the value of the Bundle object is null.

Ranjit Patnaik Introduction to Android Operating System 24 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

onStart()

When the activity enters the Started state, the system invokes this
callback. The onStart() call makes the activity visible to the user, as the
app prepares for the activity to enter the foreground and become
interactive. For example, this method is where the app initializes the code
that maintains the UI.

Ranjit Patnaik Introduction to Android Operating System 25 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

onResume()

When the activity enters the Resumed state, it comes to the foreground,
and then the system invokes the onResume() callback. This is the state in
which the app interacts with the user. The app stays in this state until
something happens to take focus away from the app. Such an event might
be, for instance, receiving a phone call, the user's navigating to another
activity, or the device screen's turning o.

Ranjit Patnaik Introduction to Android Operating System 26 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

onPause()

The system calls this method as the rst indication that the user is leaving
your activity (though it does not always mean the activity is being
destroyed); it indicates that the activity is no longer in the foreground
(though it may still be visible if the user is in multi-window mode). Use the
onPause() method to pause or adjust operations that should not continue
(or should continue in moderation) while the Activity is in the Paused
state, and that you expect to resume shortly. There are several reasons why
an activity may enter this state. For example:

Ranjit Patnaik Introduction to Android Operating System 27 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

Continue....

Some event interrupts app execution, as described in the onResume()


section. This is the most common case.
In Android 7.0 (API level 24) or higher, multiple apps run in
multi-window mode. Because only one of the apps (windows) has
focus at any time, the system pauses all of the other apps.
A new, semi-transparent activity (such as a dialog) opens. As long as
the activity is still partially visible but not in focus, it remains paused.

Ranjit Patnaik Introduction to Android Operating System 28 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

onStop()

When your activity is no longer visible to the user, it has entered the
Stopped state, and the system invokes the onStop() callback. This may
occur, for example, when a newly launched activity covers the entire
screen. The system may also call onStop() when the activity has nished
running, and is about to be terminated.

Ranjit Patnaik Introduction to Android Operating System 29 / 28


Android Operating System
Android Architecture
Android Core Building Blocks
Android Emulator
The Activity Lifecycle
Lifecycle callbacks

onDestroy()

onDestroy() is called before the activity is destroyed. The system invokes


this callback either because:
1 the activity is nishing (due to the user completely dismissing the
activity or due to nish() being called on the activity), or
2 the system is temporarily destroying the activity due to a conguration
change (such as device rotation or multi-window mode)
When the activity moves to the destroyed state, any lifecycle-aware
component tied to the activity's lifecycle will receive the ON_DESTROY
event. This is where the lifecycle components can clean up anything it
needs to before the Activity is destroyed.

Ranjit Patnaik Introduction to Android Operating System 30 / 28

You might also like