This document provides an overview of application development for Android. It discusses what Android is, the software development tools including the SDK and Eclipse IDE, Android architecture including the Linux kernel, native libraries, Dalvik VM, and application framework. It also covers application building blocks like activities, intents, services, content providers and the manifest file. The document concludes with sections on the application structure, user interface including layouts and views, and loading XML resources and using listeners.
2. What is Android?
•
•
•
•
Google’s mobile operating system
A free, open source mobile platform
A Linux-based, multiprocess, multithreaded OS
It’s not even limited to phones - you could build
a DVR, a handheld GPS, an MP3 player, etc.
• Offers an SDK and NDK
• Latest SDK version is 4.0/4.1 (Jellybean)
3. Software development
• Android SDK includes a comprehensive set of
development tools.
• The SDK is downloadable on the android
developer website.
• The officially supported integrated
development environment (IDE) is Eclipse
(currently 3.5 or 3.6) using the Android
Development Tools (ADT) Plugin
5. Linux Kernel
✓ Security model: The Linux kernel handles security between the
application and the system.
✓ Memory management: The kernel handles memory management for
you, leaving you free to develop your app.
✓ Process management: The Linux kernel manages processes
well, allocating resources to processes as they need them.
✓ Network stack: The Linux kernel also handles network communication.
✓ Driver model: The goal of Linux is to ensure that everything works.
Hardware manufacturers can build their drivers into the Linux build
6. Native Libraries
✓ Shared
libraries all written in C or C++
✓ Compiled for the particular hardware
architecture used by the phone
✓ Preinstalled by the phone vendor
✓ Can be developed using NDK
7. Android Runtime
✓ Dalvik
VM
– Google’s implementation of Java
– Optimized for mobile devices
Every Android application runs in its own process, with its
own instance of the Dalvik virtual machine. Dalvik has
been written so that a device can run multiple VMs
efficiently.
The Dalvik VM executes files in the Dalvik Executable (.dex)
format which is optimized for minimal memory footprint.
8. Application framework
✓ Activity manager: Manages the activity life cycle.
✓ Telephony manager: Provides access to telephony services as
well as some subscriber information, such as phone numbers.
✓ View system: Handles the views and layouts that make up
your user interface (UI).
✓ Location manager: Finds out the device’s geographic location.
10. Building Blocks
✓ Activities
: User Interface
✓ Intent: A mechanism for describing a specific
action
✓ Service: A task that runs in the background
without user interaction
✓ Content providers: is a set of data wrapped up
in a custom API to read and write it
13. Intents
✓ Activities and services — are
activated through messages, called
intents.
✓ Intent object, is a data structure holding a description of an
operation to be performed.
Implicit intents
Explicit intents
Intent intent1 = new Intent(v.getContext(), thirdscreenn.class);
startActivity(intent1);
14. Services
✓ A service is a component that runs in the background to
perform long-running operations or to perform work for
remote processes.
✓ 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.
✓ A service does not provide a user interface.
15. Content providers
✓ A content provider manages a shared set of application data.
✓ You can store the data in the file system, a SQLite database, on
the web, or any other persistent storage location your
application can access.
✓ Through the content provider, other applications can query or
even modify the data (if the content provider allows it).
✓ A content provider is implemented as a subclass of
ContentProvider and must implement a standard set of APIs
that enable other applications to perform transactions
16. The AndroidManifest.xml File
✓ Every application must have an AndroidManifest.xml file.
✓ It names the Java package for the application. The package
name serves as a unique identifier for the application.
✓ It describes the components of the application — the
activities, services, broadcast receivers, and content providers
that the application is composed of.
✓ It determines which processes will host application
components.
✓ It declares the minimum level of the Android API that the
application requires.
17. AVD (Android Virtual Device)
• An Android Virtual Device (AVD) is an emulator configuration
that lets you model an actual device by defining hardware and
software options to be emulated by the Android Emulator.
25. Listeners
✓ Tell Android which object to callback when the user touches or clicks
the view
✓ Use setOnClickListener() method that needs to Be passed an object
that implements the OnClickListener Java interface
✓ Set android:onClick property with the method name that handles the
click action
button.setOnClickListener(new OnClickListener()
{
public void onClick(View v) {
// TODO Auto-generated method stub
Intent j = new Intent(v.getContext(),mediaplayer.class);
j.putExtra(mediaconstant.MEDIA_MODE, mediaconstant.MEDIA_PAUSE);
startService(j);
}
} );