KEMBAR78
Android | PDF | Runtime System | Android (Operating System)
0% found this document useful (0 votes)
8 views108 pages

Android

The document provides an overview of the Android operating system, detailing its open-source nature, architecture, and key features such as multitasking and media support. It discusses the various layers of Android architecture, including applications, application framework, and runtime, as well as the Linux kernel's role in managing hardware resources. Additionally, it covers the structure of Android applications, including layouts and UI components like buttons and text views.

Uploaded by

Likanos Tegene
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views108 pages

Android

The document provides an overview of the Android operating system, detailing its open-source nature, architecture, and key features such as multitasking and media support. It discusses the various layers of Android architecture, including applications, application framework, and runtime, as well as the Linux kernel's role in managing hardware resources. Additionally, it covers the structure of Android applications, including layouts and UI components like buttons and text views.

Uploaded by

Likanos Tegene
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 108

ADAMA SCIENCE AND TECHNOLOGY UNIVERSITY

SCHOOL OF ELECTRICAL AND ENGINEERING AND COMPUTING


Department of Computer Science and Engineering

Arranged By: Guta T.



Topics
✔ What is Android?
✔ Evolution of Android
✔ Why Android?
✔ Features
✔ Architecture
What is Android ?

It is a open source software platform and operating system for mobile devices


Based on the Linux kernel


Developed by Google and later the Open Handset Alliance (OHA)


Allows writing managed code in the Java language


Android has its own virtual machine i.e. DVM(Dalvik Virtual Machine),which
is used for executing the android application.


Google purchased the initial developer of the software , android incorporated in
2005.What is Android ?
OHA INCLUDED COMPANIES
Why Android ?
Android-Features

Open Source

GUI

Accessibility

Storage

Messaging

Media Support

Multitasking

Resizable widgets

Multi Languages

Voice based features
Android Architecture
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.
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 different types of services activity manager, notification
manager, view system, package manager etc. which are helpful for the
development of our application according to the prerequisite.
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 efficiently.
● 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.
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 OpenGLboth cross-language, cross-platform application program interface (API)
are used for 2D and 3D computer graphics.

SQLite provides database support andFreeTypeprovides 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.
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
Linux Kernel Features-

Security: The Linux kernel handles the security between the application and the
system.

Memory Management: It efficiently 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 effectively 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.
Android Runtime-

What is runtime? In a simplest term it is a system used by operating
system which takes care of converting the code that you write in a
high level language like Java to machine code and understand by
CPU/Processor.

Android runtime= DVM + Core Java Libraries
Android Runtime-
Android Runtime-
JDK-Installation
Android Environment

Android Environment The Android SDK (software development kit) is a set of development
tools used to develop applications for the Android platform

The Android SDK includes the following:

– Required libraries.

– Debugger.

– An emulator. (AVD)

– Relevant documentation for the Android application program interfaces (APIs).

– Sample source code.

– Tutorials for the Android OS.


Android Studio-Installation
Android Studio
Creating Android Application
Creating Android Application
Creating Android Application
Creating Android Application
Structure of Android Application
Structure of Android Application
✔ AndroidManifest.xml: Every project in Android includes a manifest file,
which isAndroidManifest.xml, stored in the root directory of its project
hierarchy. The manifest file is an important part of our app because it defines
the structure and metadata of our application, its components, and its
requirements. This file includes nodes for each of the Activities, Services,
Content Providers and Broadcast Receiver that make the application and using
Intent Filters and Permissions, determines how they co-ordinate with each
other and other applications.
✔ Java: The Java folder contains the Java source code files. These files are used
as a controller for controlled UI (Layout file). It gets the data from the Layout
file and after processing that data output will be shown in the UI layout. It
works on the backend of an Android application.
Structure of Android Application
✔ Drawable: A Drawable folder contains resource type file (something that
can be drawn). Drawable may take a variety of file like Bitmap (PNG,
JPEG), Nine Patch, Vector (XML), Shape, Layers, States, Levels, and
Scale.
✔ layout: A layout defines the visual structure for a user interface, such as
the UI for an Android application. This folder stores Layout files that are
written in XML language. You can add additional layout objects or widgets
as child elements to gradually build a View hierarchy that defines your
layout file.
Structure of Android Application
✔ mipmap: Mipmap folder contains the Image Asset file that can be used in
Android Studio application. You can generate the following icon types like
Launcher icons, Action bar and tab icons, and Notification icons.
✔ values: This is the directory for other various XML files that contain collection
of resources such as Strings and Color definitions colors.xml: colors.xml file
contains color resources of the Android application. Different color values are
identified by a unique name that can be used in the Android application program.
strings.xml: The strings.xml file contains string resources of the Android
application. The different string value is identified by a unique name that can be
used in the Android application program. This file also stores string array by using
XML language.
Structure of Android Application
What is Android Layouts?

An Android layout is a class that handles arranging the way its
children appear on the screen. Anything that is a View (or inherits
fromView) can be a child of a layout. All of the layouts inherit
fromViewGroup(which inherits fromView) so you can nest
layouts.You could also create your own custom layout by making a
class that inherits fromViewGroup.
What is Android Layouts?

An Android layout is a class that handles arranging the way its
children appear on the screen. Anything that is a View (or inherits
fromView) can be a child of a layout. All of the layouts inherit
fromViewGroup(which inherits fromView) so you can nest
layouts.You could also create your own custom layout by making a
class that inherits fromViewGroup.
What is Android Layouts?

An Android layout is a class that handles arranging the way its
children appear on the screen. Anything that is a View (or inherits
fromView) can be a child of a layout. All of the layouts inherit
fromViewGroup(which inherits fromView) so you can nest
layouts.You could also create your own custom layout by making a
class that inherits fromViewGroup.
Layouts

Layouts Linear Layout-A Linear Layout aligns each of the child
View in either a vertical or a horizontal line. A vertical layout has a
column of Views, whereas in a horizontal layout there is a row of
Views. It supports a weight attribute for each child View that can
control the relative size of each child View within the available space.

Relative Layout- It is flexible than other native layouts as it lets us to
define the position of each child View relative to the other views and
the dimensions of the screen
Layouts

Table Layout - The Table Layout groups views into rows and
columns Grid Layout-It was introduced in Android 4.0 (API level 14),
the Grid Layout used a rectangular grid of infinitely thin lines to lay
out Views in a series of rows and columns. The Grid Layout is
incredibly flexible and can be used to greatly simplify layouts and
reduce or eliminate the complex nesting often required to construct
UIs using the layouts described before.
Layouts

Frame Layout- It is the simplest of the Layout Managers that pins each

child view within its frame. By default the position is the top-left corner,

though the gravity attribute can be used to alter its locations. You can add

multiple children stacks each new child on top of the one before, with

each new View potentially obscuring the previous ones.



Absolute Layout enables you to specify the exact location of its

children.
Layouts
Views
● View is the basic building block of UI in Android. View refer toAndroid.view.Viewclass,

which is the super class of all the GUI components like Text View, Button, Image Button

etc. Views also know as Widgets.


● Views Category

1. Basic Views

2. Picker Views

3. List Views
Syntax for creating views

Attribute that will define how that view

will look on the screen of the

application along with a value for the

attribute.
TextView

In android,TextViewis a user interface control that is used to set and

display the text to the user based on our requirements. The TextView

control will act as like label control and it optionally allow them to

edit text. In android, we can create a TextView control in two ways

either in XML layout file or create it inActivityfile programmatically


Create a TextView in Layout File

a
Create a TextView in Layout File

a
Create a TextView in Layout File

a
Button

In android, Button is a user interface control that is used to perform an
action whenever the user clicks or tap on it.

Generally, Buttons in android will contain a text or an icon or both and
perform an action when the user touches it.

In android, we have a different type of buttons available to use based on
our requirements, those are Toggle Button, Radio Button, Image Button.

In android, we can create a Button control in two ways either in the
XML layout file or create it in the Activityfile programmatically
Create Button in XML Layout File

s
Create Button in XML Layout File

s
ImageView and ImageButton in Android

ImageView and ImageButton in Android ImageViewis used to show any
picture on the user interface.
ToggleButton

Android Toggle Button can be used to display checked/unchecked
(On/Off) state on the button. It is beneficial if user have to change the
setting between two states. It can be used to On/Off Sound, Wifi,
Bluetooth etc. Since Android 4.0, there is another type of toggle button
calledswitchthat provides slider control.
ToggleButton

Android Toggle Button can be used to display checked/unchecked
(On/Off) state on the button. It is beneficial if user have to change the
setting between two states. It can be used to On/Off Sound, Wifi,
Bluetooth etc. Since Android 4.0, there is another type of toggle button
calledswitchthat provides slider control.
Create ToggleButton in XML Layout File Create ToggleButton Control in Activity File
RadioButton

In android,Radio Button is a two-states button that can be either
checked or unchecked and it's the same as CheckBox control, except
that it will allow only one option to select from the group of options.

The user can press or click on the radio button to make it select. In
android,CheckBox control allow users to change the state of control
either Checked or Unchecked but the radio button cannot be unchecked
once it is checked.

Generally, we can use RadioButton controls in an android application to
allow users to select only one option from the set of values.
RadioButton

In android,Radio Button is a two-states button that can be either
checked or unchecked and it's the same as CheckBox control, except
that it will allow only one option to select from the group of options.

The user can press or click on the radio button to make it select. In
android,CheckBox control allow users to change the state of control
either Checked or Unchecked but the radio button cannot be unchecked
once it is checked.

Generally, we can use RadioButton controls in an android application to
allow users to select only one option from the set of values.
RadioButton

In android, we use radio buttons with in aRadioGroupto combine
multiple radio buttons into one group and it will make sure that users
can select only one option from the group of multiple options. By
default, the android RadioButton will be in OFF(Unchecked) state. We
can change the default state of RadioButton by usin
gandroid:checkedattribute.

In case, if we want to change the state of RadioButtonto ON(Checked),
then we need to set android:checked ="true" in our XML layout file. In
android, we can createRadioButtoncontrol in two ways either in the
XML layout file or create it in theActivityfile programmatically.
ImageView and ImageButton in Android

ImageView and ImageButton in Android ImageViewis used to show any
picture on the user interface.
RadioButton

In cally.
ImageView and ImageButton in Android

ImageView and ImageButton in Android ImageViewis used to show any
picture on the user interface.
ImageView and ImageButton in Android

ImageView and ImageButton in Android ImageViewis used to show any
picture on the user interface.
ImageView and ImageButton in Android

ImageButton has the same property as ImageView. Only one feature is
extra, which is, images set through ImageButton are clickable, and
actions can be attached with them upon clicking. Here is how you
define an ImageButton in the layout XML file:
Progress Bar
Progress Bar


Progress Bar In android,ProgressBaris a user interface control that is
used to indicate the progress of an operation. For example, downloading
a file, uploading a file.

By default the ProgressBarwill be displayed as a spinning wheel, in case
if we want to show it like a horizontal bar then we need to change the
style property to horizontal

Like style="?android:attr/progressBarStyleHorizontal".
Progress Bar


Progress Bar In android, the ProgressBarsupports two types of modes to
show the progress, those are Determinateand Indeterminate.

Generally, we use the Determinate progress mode in progress bar when
we want to show the quantity of progress has occurred.

For example, the percentage of file downloaded, number of records
inserted into a database, etc.

To use Determinate progress, we need to set the style of the progress bar
to Widget_ProgressBar_Horizontal or progressBarStyleHorizontal
and set the amount of progress using android:progress attribute.
Progress Bar


In android, the ProgressBarsupports two types of modes to show the
progress, those areDeterminateandIndeterminate.

Generally, we use the Determinate progress mode in progress bar when
we want to show the quantity of progress has occurred.

For example, the percentage of file downloaded, number of records
inserted into a database, etc.

To use Determinate progress, we need to set the style of the progress bar
to Widget_ProgressBar_Horizontal or progressBarStyleHorizontal
and set the amount of progress using android:progress attribute.
Progress Bar


In android,
Progress Bar


By using setProgress(int) method,we can update the percentage of
progress displayed in app or by calling increment ProgressBy(int)
method, we can increase the value of current progress completed based
on our requirements.

Generally, when the progress value reaches100 then the progress bar is
full.

By using android:max attribute we can adjust this default value.
Progress Bar


By using setProgress(int) method,we can update the percentage of
progress displayed in app or by calling increment ProgressBy(int)
method, we can increase the value of current progress completed based
on our requirements.

Generally, when the progress value reaches100 then the progress bar is
full.

By using android:max attribute we can adjust this default value.
Progress Bar


Generally, we use the Indeterminate progress mode in progress bar
when we don't know how long an operation will take or how much
work has done.

In indeterminate mode the actual progress will not be shown, only the
cyclic animation will be shown to indicate that some progress is
happing like as shown in the above progress bar loading images.

By using progressBar.setIndeterminate(true) in activity file
programmatically or using android:indeterminate = "true" attribute
in XML layout file, we can enable Indeterminate progress mode
Progress Bar


file:///home/guta/Pictures/Screenshots/Screenshot%20from%202024-
05-20%2015-37-00.png
Progress Bar


file:///home/guta/Pictures/Screenshots/Screenshot%20from%202024-
05-20%2015-37-00.png
AutoCompleteTextView


In Android, AutoCompleteTextView is a
view i.e similar to EditText, except that it
displays a list of completion suggestions
automatically while the user is typing.


A list of suggestions is displayed in drop
down menu from which user can choose an
item which actually replace the content of
Editbox with that.
AutoCompleteTextView

Generally, the dropdown list of suggestions can be obtained from the
data adaptor and those suggestions will be appeared only after giving
the number characters defined in the Thresholdlimit.

The Thresholdproperty of AutoCompleteTextView is used to define
the minimum number of characters the user must type to see the list of
suggestions.

The dropdown list of suggestions can be closed at any time in case if no
item is selected from the list or by pressing thebackorenterkey.

In android, we can create an AutoCompleteTextView control in two
ways either in the XML layout file or create it in the Activity file
programmatically.
AutoCompleteTextView

j
AutoCompleteTextView

j
AutoCompleteTextView

j
ANDROID ACTIVITY

In android,Activity represents a single screen with a user interface (UI)
of an application and it will acts an entry point for users to interact with
an app.

Generally, the android apps will contain multiple screens and each
screen of our application will be an extension of Activity class.

By using activities, we can place all our android application UI
components in a single screen.

From the multiple activities in android app, one activity can be marked
as amain activityand that is the first screen to appear when we launch
the application.

In android app each activity can start another activity to perform
different actions based on our requirements.
ANDROID ACTIVITY

To use activities in our application we need to define an activities with
required attributes in manifest file (AndroidMainfest.xml) like as
shown below
ANDROID ACTIVITY

In android application, activities can be implemented as a subclass
ofActivityclass like as shown below.
ANDROID ACTIVITY

onCreate(Bundle) is where you initialize your activity. Most
importantly, here you will usually call setContentView(int) with a
layout resource defining your UI, and using findViewById(int) to
retrieve the widgets in that UI that you need to interact with
programmatically

onPause() is where you deal with the user pausing active interaction
with the activity. Any changes made by the user should at this point be
committed (usually to the Content Provider holding the data). In this
state the activity is still visible on screen
ANDROID ACTIVITY: State of activities

As a user navigates throughout an app, Android maintains the visited
activities in a stack, with the currently visible activity always placed at
the top of the stack.

At any point in time a particular activity can be in one of the following
4 states:
Android Activity Life Cycle

Any Android activity goes through a certain life cycle during its life
inside the Android app. The following diagram shows the whole
Activity lifecycle: Android Activity Life Cycle Generally, the activities
in our android application will go through a different stages in their life
cycle.

In android, Activity class have 7 callback methods like onCreate(),
onStart(), onPause(), onRestart(), onResume(), onStop() and
onDestroy() to describe how the activity will be have at different
stages.
Android Activity Life Cycle
q
Android Activity Life Cycle
q
Android Activity Life Cycle
q
Android Activity Life Cycle
q
What is Intent in Android?

In Android, it is quite usual for users to witness a jump from one
application to another as a part of the whole process, for example,
searching for a location on the browser and witnessing a direct jump
into Google Maps or receiving payment links in Messages Application
(SMS) and on clicking jumping to PayPal or G-Pay (Google Pay).

This process of taking users from one application to another is achieved
by passing the Intent to the system.

Intents, in general, are used for navigating among various activities
within the same application, but note, is not limited to one single
application, i.e., they can be utilized from moving from one application
to another as well.
What is Intent in Android?

Android usesIntentfor communicating between the components of an
Application and also from one application to another application.

Intent are the objects which is used in android for passing the
information among Activities in an Application and from one app to
another also.

Intent are used for communicating between the Application components
and it also provides the connectivity between two apps.

In android, Intents are the objects of android.content.Intenttypes and
intents are mainly useful to perform the following things.
What is Intent in Android?

In android, Intents are the objects of android.content.Intenttypes and
intents are mainly useful to perform the following things.
Android Intent Structure

Android Intent Structure The primary pieces of information in an intent
are:

Action → The general action to be performed, such as ACTION_VIEW,
ACTION_EDIT, ACTION_MAIN, etc.

Data → The data to operate on, such as a person record in the contacts
database, expressed as a URI (Uniform Resource Identifier).

Category→ Generally, the android category is optional for intents and it
specifies the additional information about the type of component that
should handle an intent. We can specify a category for intent by using
addCategory().

The above properties will represent the characteristics of an intent
Android Intent Types

There are two types of intents in android:
1. Implicit and
2.Explicit
Implicit Intent

In implicit intent target component name is not passed in the intent at the
time of creating it.

The Android system decided itself which component of which application
should receive this intent.

Intent i=new Intet(Intent.ACTION_VIEW);

i.setData(Uri.parse(https://amazon.in));

startActivity(i);
Explicit Intent

In explicit intent target component name is directly passed in the intent at
the time of creating it.
Intent Filter

An Intent filter is an expression in an app's manifest file that specifies the
types of intents that the component would like to receive.
Attributes:
1) android:icon

An icon that represents the parent activity, service, or broadcast receiver
when that component is presented to the user as having the capability
described by the filter.

This attribute must be set as a reference to a drawable resource
containing the image definition.

The default value is the icon set by the parent component's icon
attribute.

If the parent does not specify an icon, the default is the icon set by the
<application> element.
Attributes:
2) android:label

A user-readable label for the parent component.

This label, rather than the one set by the parent component, is used
when the component is presented to the user as having the capability
described by the filter.

The label should be set as a reference to a string resource, so that it can
be localized like other strings in the user interface.

However, as a convenience while you're developing the application, it
can also be set as a raw string. The default value is the label set by the
parent component.

If the parent does not specify a label, the default is the label set by the
<application> element's label attribute
Attributes:
3) android:priority

The priority that should be given to the parent component with regard to
handling intents of the type described by the filter.

This attribute has meaning for both activities and broadcast receivers:

It provides information about how able an activity is to respond to an intent
that matches the filter, relative to other activities that could also respond to
the intent.

When an intent could be handled by multiple activities with different
priorities, Android will consider only those with higher priority values as
potential targets for the intent.
Attributes:
3) android:priority

It controls the order in which broadcast receivers are executed to receive
broadcast messages.

Those with higher priority values are called before those with lower values.
(The order applies only to synchronous messages; it's ignored for
asynchronous messages.)

The value must be an integer, such as "100". Higher numbers have a higher
priority. The default value is 0.

In certain circumstances the requested priority is ignored and the value is
capped to 0.

This occurs when: A non-privileged application requests any priority >0 A
privileged application requests a priority >0 for ACTION_VIEW,
ACTION_SEND, ACTION_SENDTO or ACTION_SEND_MULTIPLE

Android-Services

Referenc https://developer.android.com/develop/background-work/services

What are Android Services?
• Service is basically a process.Android serviceis a component that runs in
the background in order to perform long-running operations without
interacting with the user and it works even if the application is destroyed.
• Another application component can start a service and it continues to run in
the background even if you switch to another application.
Type of Android Services?
•a
Android Services
1. Foreground Services
• Foreground services are those services that are visible to the users. The
users can interact with them at ease and track what's happening. These
services continue to run even when users are using other applications.
The perfect example of this is Music Player and Downloading.
2. Background Services
• These services run in the background, such that the user can't see or
access them. These are the tasks that don't need the user to know them.
Syncing and Storing data can be the best example.
Android Services
3. Bound Services
• Bound service runs as long as some other application componentis
bound to it. Many components can bind to one service at a time, but
once they all unbind, the service will destroy. To bind an application
component to the service, bindService() is used.
Android- Services Life cycle
• Android Services life cycle can have two forms of services.
• The lifecycle of a service follows two different paths, namely:
1.Started
2.Bounded
Android- Services Life cycle
Started Service
• A service is started when an application component calls startService()
method.
• Once started, a service can run in the background indefinitely, even if
the component which is responsible for the start is destroyed.
• It is stopped by using the stopService() method. The service can also
stop itself by calling thestopSelf()method
Android- Services Life cycle
Bound Service
• A service is bound when an application component binds to it by
calling bindService().
• Bound service offers a client-server interface that allows components
to interact with the service, send requests and, get results. It
processes across inter-process communication (IPC).
• The client can unbind the service by calling the unbindService()
method.
Android- Services Life cycle
Methods of Android Services
c
IntentService()
There's an additional service class, that extends Service class,
IntentService Class.
• It is a base class for services to handle asynchronous requests.
• It enables running an operation on a single background.
• It executes long-running programs without affecting any user's
interface interaction.
• Intent services run and execute in the background and terminate
themself as soon as they are executed completely.
IntentService()

• Certain important features of Intent are :


• It queues up the upcoming request and executes them one by one.
• Once the queue is empty it stops itself, without the user's
intervention in its lifecycle.
• It does proper thread management by handling the requests on a
separate thread.
Reference
1. College Sidekick
2. https://developer.android.com/get-started/codelabs
3. https://developer.android.com/develop/background-work/service
s

You might also like