ANDROID APP
APPS
APPLICATIO
N
FRAMEWOR
K
NATIVE
LIBRARY
ANDROID
RUNTIME
LINUX
KERNEL
APP
S
contact
APPLICATI
ON
FRAMEWO
RK
NATIVE
LIBRARY
Phone
ANDROID
RUNTIME
Third party
app
LINUX
KERNEL
browser
APP
S
Activity
Manager
Notificati
on
Manager
APPLICATI
ON
FRAMEWO
RK
NATIVE
LIBRARY
ANDROID
RUNTIME
LINUX
KERNEL
Window
Manager
Content
Provider
View
System
Package
Manager
Telephon
ey
Manager
Location
Manager
APP
S
APPLICATI
ON
FRAMEWO
RK
NATIVE
LIBRARY
Surface
Manager
Media
Framework
Sql Lite
FreeType
Webkit
ANDROID
RUNTIME
LINUX
KERNEL
Core
Library
Dalvik VM
APP
S
APPLICATI
ON
FRAMEWO
RK
NATIVE
LIBRARY
Dis
pla
y
Driv
er
Flash Driver
Blu
eto
oth
Driv
er
ANDROID
RUNTIME
Camera Driver
LINUX
KERNEL
ANDROID RUNTIME
Android apps run within the Dalvik Virtual Machine (Dalvik VM),
which is
similar to a Java VM but has been optimized for devices with limited
memory and
processing capacity.
Android apps are initially compiled to the Java byte code using the
Java compiler,
but they have an additional compilation step that transforms the
Java byte code to the Dalvik byte code, suitable to run within the
Dalvik VM.
Java source
Java
Compiler
*.class files
java
bytecode
Dalvik
Compiler(dex
)
*.dex files
Dalvik Byte
Code
THE APPLICATION
FRAMEWORK
The Application Framework is the part of the Android platform, most
familiar
to developers. It is delivered as a set of Java libraries and allows
you to build user
interfaces, interact with device capabilities such as the camera or
location services,
load and work with various types of application resources, and
perform many
more useful tasks.
APPLICATIONS
At the top of the stack sits the humble application, the component
that actually
delivers value to the user. Android comes with a set of applications
that provide
base functionality such as managing contacts, using the phone,
checking email,
and browsing the Web. The key to Android's success is the vast
array of third-party
applications that can be installed, which allow users to do things
such as stream live
sports' events, edit a movie captured on the phone, interact with
friends through
THE APPLICATION
MANIFEST
All Android applications have a manifest file (AndroidManifest.xml) that tells the
Android platform everything it needs to know to successfully run the application,
including the following:
Minimum API Level required by the application
Hardware/software features used or required by the application
Permissions required by the application
The initial screen (Android activity) to start with when the application
is launched
Libraries, other than AAF, required by the application
And so on
VERSIONS OF ANDROID
Identifying the version of the Android platform can be somewhat
confusing; there is
a version number, API level, and nickname, and these are
sometimes
used interchangeably.
The version number represents a release of the platform.
Sometimes, a new release
is created to deliver new capabilities, while sometimes it is created
to fix bugs.
The API level represents a set of capabilities. As the API level
increases, new
capabilities are delivered to the developer.
4.4 19 KitKat
10/31/2013
4.3 18 Jelly
Bean
07/24/2013
4.2, 4.22 17
11/13/2012
4.1, 4.11 16
07/09/2012
4.0.3, 4.0.4 15
Ice Cream
Sandwich
12/16/2011
2.3, 2.3.1,
2.3.2 9
12/06/2010
2.3.3, 2.3.4 10
Gingerbread
02/02/2011
3.0.x 11
02/22/2011
3.1.x 12
05/10/2011
3.2 13
Honeycomb
07/15/2011
2.2.x 8 Froyo
05/20/2010
2.1.x 7 clair
01/12/2010
2.0.1 6
12/03/2009
2.0 5
10/26/2009
1.6 4 Donut
09/15/2009
THE ANDROID
APPLICATIONS
Now, let's spend some time discussing applicationsthose things
we write that
provide value to the user. Android applications are made up of
various types of
classes and resources. The following sections describe the different
types
of classes or building blocks that an application can be composed
of.
ACTIVITIES
One of the most fundamental parts of an Android application is an
activity.
An activity provides a single function that a user can perform with
an application
such as list contacts, enter new contact, and display location(s) on
a map. A single
application is composed of many activities.
A user interacts with an activity through one or more Views, which
are described
later in this chapter. If you are familiar with the Model-ViewController pattern,
you would have noticed that activities fulfill the role of the
THE STATES OF AN
ACTIVITY
State Description
Running The activity has been created and initialized, and is visible
and
available to the user for interaction.
Paused The activity view is being partially blocked by another
activity.
Stopped The activity is no longer visible to the user, The activity
has not been
destroyed, and state is retained but it is placed in the background
and no processing is allowed.
Typical Processing
onCreate
When an activity is
created,
generally from a user
choosing
to start the app
Create Views
Initialize variables
Allocate long-lived
resources
onStart
After onCreate or
onRestart
and right before an
activity becomes
visible to the user
Allocate resources
onRestart
An activity is being
placed back in
the foreground,
generally because
the user has selected
the back button
Allocate resources
onDestroy
Cleanup resources
that may have been
allocated in onCreate
Called
THE EVENTS OF A
ACTIVITY
Event
SERVICES
Services are components that run in the background to perform
long-running
operations with no direct user interface. Services may load data
into a cache,
play music, or perform some other type of processing, while a user
interacts
with other activities uninterrupted.
CONTENT PROVIDERS
Content providers manage access to a central repository of data
such as contacts.
A content provider is a part of an application, which usually
provides a user
interface to manage its data. A standard interface is also provided,
which allows
other applications to access its repository.