Beruflich Dokumente
Kultur Dokumente
By David Sudharsan R
Agenda
What is Android?
Android Features
Android Architecture
Application Components
Setting up the Development Environment
Developing an Application
Building an Application
Testing the Application using Emulator
Testing the Application using a Device
Debugging the Application
Publishing the Application
10 February 2012
What is Android
10 February 2012
Android Features
10 February 2012
Android Architecture
10 February 2012
Kernel
Android relies on Linux version 2.6 for core system services such as security,
memory management, process management, network stack, and driver model.
The kernel acts as an abstraction layer between the hardware and the rest of the
software stack.
Runtime
Android includes a set of core libraries that provides most of the functionality
available in the core libraries of the Java programming language.
Android application runs in its own process, with its own instance of the Dalvik
Virtual Machine (VM).
The Dalvik VM executes files in the Dalvik Executable .dex format which is
optimized for minimal memory footprint.
The VM is register-based, and runs classes compiled by a Java language
compiler that have been transformed into the .dex format by the included "dx"
tool.
The Dalvik VM relies on the Linux kernel for underlying functionality such as
threading and low-level memory management.
10 February 2012
Libraries
Android includes a set of C/C++ libraries used by various components of the
Android system.
System C library - a BSD-derived implementation of the standard C system
library (libc), tuned for embedded Linux-based devices
Media Libraries - based on PacketVideo's OpenCORE; the libraries support
playback and recording of many popular audio and video formats, as well as
static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG
Surface Manager - manages access to the display subsystem and seamlessly
composites 2D and 3D graphic layers from multiple applications
LibWebCore - a modern web browser engine which powers both the Android
browser and an embeddable web view
SGL - the underlying 2D graphics engine
3D libraries - an implementation based on OpenGL ES 1.0 APIs; the libraries
use either hardware 3D acceleration (where available) or the included, highly
optimized 3D software rasterizer
FreeType - bitmap and vector font rendering
SQLite - a powerful and lightweight relational database engine available to all
applications
10 February 2012
Application Framework
Android offers developers the ability to build extremely rich and innovative
applications.
Developers can take advantage of the device hardware, access location
information, run background services, set alarms, add notifications to the status
bar, and much, much more.
The application architecture is designed to simplify the reuse of components.
View system is a rich and extensible set of Views that can be used to build an
application, including lists, grids, text boxes, buttons, and even an embeddable
web browser.
Content Providers enable applications to access data from other applications
(such as Contacts), or to share their own data.
Resource Manager, provides access to non-code resources such as localized
strings, graphics, and layout files.
Notification Manager enables all applications to display custom alerts in the
status bar.
Activity Manager manages the lifecycle of applications and provides a common
navigation back stack.
10 February 2012
Application
Android will ship with a set of core applications including an email client, SMS
program, calendar, maps, browser, contacts, and others.
All applications are written using the Java programming language.
Underlying all applications is a set of services and systems, including views,
activities, content providers, resources, intents, etc.
The Android SDK tools compile the code along with any data and resource files
into an Android package, an archive file with an .apk suffix.
A single .apk file is considered to be one application and is the file that Androidpowered devices use to install the application.
Every application runs in its own Linux process. Each process has its own virtual
machine (VM), so an application's code runs in isolation from other applications.
Each application, by default, has access only to the components that it requires
to do its work and no more.
An application can request permission to access device data such as the user's
contacts, SMS messages, the mountable storage (SD card), camera, Bluetooth,
and more. All application permissions must be granted by the user at install time.
10 February 2012
Application Components
Activities
An activity represents a single screen with a user interface.
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.
An activity is implemented as a subclass of Activity.
Services
A service is a component that runs in the background to perform long-running
operations or to perform work for remote processes.
A service does not provide a user interface. For example, a service might play
music in the background while the user is in a different application.
A service is implemented as a subclass of Service.
10 February 2012
10
Content providers
A content provider manages a shared set of application data.
You can store the data in the file system, an SQLite database, on the web, or
any other persistent storage location the application can access.
Through the content provider, other applications can query or even modify the
data.
For example the Contact content provider allows to view or add or modify
contacts.
A content provider is implemented as a subclass of ContentProvider.
Broadcast receivers
A broadcast receiver is a component that responds to system-wide broadcast
announcements.
Many broadcasts originate from the systemfor example, a broadcast
announcing that the screen has turned off.
A broadcast receiver is implemented as a subclass of BroadcastReceiver.
10 February 2012
11
Intents
Activities, services, and broadcast receivers are activated by an asynchronous
message called an intent.
Intents binds individual components to each other at runtime whether the
component belongs to your application or another.
An intent is created with an Intent object, which defines a message to activate
either a specific component or a specific type of component, an intent can be
either explicit or implicit, respectively.
For activities and services, an intent defines the action to perform (for example,
to "view" or "send" something) and may specify the URI of the data to act on. For
example, an intent might convey a request for an activity to show an image or to
open a web page.
For broadcast receivers, the intent simply defines the announcement being
broadcast.
The content provider, is not activated by intents. It is activated when targeted by
a request from a ContentResolver.
10 February 2012
12
Manifest file
The application must declare all its components in the Manifest file, which must
be at the root of the application project directory.
To identify any user permissions the application requires, such as Internet
access or read-access to the user's contacts.
To declare the minimum API Level required by the application, based on which
APIs the application uses.
To declare hardware and software features used or required by the application,
such as a camera, bluetooth services, or a multitouch screen.
To declare the API libraries the application needs to be linked against (other than
the Android framework APIs), such as the Google Maps library.
10 February 2012
13
Resources
An Android application is composed of other resources such as images, audio
files, and anything relating to the visual presentation of the application.
Application resources makes it easy to update various characteristics of your
application without modifying code such as different languages and screen sizes.
For every resource in the Android project, the SDK build tools define a unique
integer ID, which can be used to reference the resource from your application
code or from other resources defined in XML.
10 February 2012
14
10 February 2012
15
10 February 2012
16
10 February 2012
17
10 February 2012
18
10 February 2012
19
10 February 2012
20
10 February 2012
21
10 February 2012
22
10 February 2012
23
10 February 2012
24
10 February 2012
25
10 February 2012
26
Configuring AVD
1. The Android Virtual Devices (AVD) can be configured by launching
the AVD Manager from Eclipse menu under Windows or by the exe in
the installation path. Click New.. to configure a new device.
10 February 2012
27
Configuring AVD
2. Provide the configurations of the virtual device and then click Create
AVD
10 February 2012
28
Configuring AVD
3. The new AVD is created and added to the list
10 February 2012
29
Configuring AVD
4. Select the device to be launched and click Start... In the new window
displayed, click Launch
10 February 2012
30
Configuring AVD
5. The AVD is launched.
10 February 2012
31
Developing an Application
1. Create a new android Project in Eclipse
10 February 2012
32
Developing an Application
2. Provide the project details
10 February 2012
33
Developing an Application
3. Select the Android version for build
10 February 2012
34
Developing an Application
4. Provide the application details
10 February 2012
35
Developing an Application
5. Application structure created by Eclipse
10 February 2012
36
Developing an Application
6. Activity source code
10 February 2012
37
Developing an Application
7. Designing the layout for the activity
10 February 2012
38
Developing an Application
8. The layout in XML format
10 February 2012
39
Developing an Application
9. Defining the resources
10 February 2012
40
Developing an Application
10. Android Manifest file
10 February 2012
41
Building an Application
1. Building the application in Eclipse
10 February 2012
42
Building an Application
2. Build output files
10 February 2012
43
Building an Application
3. Build process
10 February 2012
44
Building an Application
4. Build steps
10 February 2012
45
Building an Application
The Build Steps:
The Android Asset Packaging Tool (aapt) takes the application resource files, such as
the AndroidManifest.xml file and the XML files for the Activities, and compiles them. An
R.java is also produced so resources can be referenced from Java code.
The aidl tool converts any .aidl interfaces into Java interfaces.
All of Java code, including the R.java and .aidl files, are compiled by the Java compiler
and .class files are output.
The dex tool converts the .class files to Dalvik byte code. Any 3rd party libraries and
.class files that are included in the project are also converted into .dex files so that they
can be packaged into the final .apk file.
All non-compiled resources (such as images), compiled resources, and the .dex files
are sent to the apkbuilder tool to be packaged into an .apk file.
Once the .apk is built, it must be signed with either a debug or release key before it can
be installed to a device.
Finally, if the application is being signed in release mode, align the .apk with the
zipalign tool. Aligning the final .apk decreases memory usage when the application is
running on a device.
10 February 2012
46
Building an Application
5. Build output
10 February 2012
47
Building an Application
6. Structure of resources.ap_
10 February 2012
48
Building an Application
7. Structure of .apk
10 February 2012
49
10 February 2012
50
10 February 2012
51
10 February 2012
52
10 February 2012
53
10 February 2012
54
Debugging an Application
1. Set the break points in the source code
10 February 2012
55
Debugging an Application
2. Launch the debugger
10 February 2012
56
Debugging an Application
3. Start the debugger
10 February 2012
57
Debugging an Application
4. Application in the debug mode
10 February 2012
58
10 February 2012
59
Publishing an Application
10 February 2012
60
Android Market is a service that makes it easy for users to find and
download Android applications to their Android-powered devices,
either from the Android Market application on their device or from
the Android Market web site (market.android.com).
To publish an application on Android Market, first the developer
needs to register with the service using a Google account and agree
to the terms of service.
Once registered, the developer can upload the application to the
service whenever and update it as many times as required, and then
publish it when ready. Once published, users can see the
application, download it, and rate it.
10 February 2012
61
10 February 2012
62
10 February 2012
63
References
https://knowmax.ultimatix.net
http://developer.android.com/sdk/index.html
http://developer.android.com/guide/index.html
http://developer.android.com/reference/packages.html
http://developer.android.com/resources/index.html
10 February 2012
64
Thank You
10 February 2012
65