30-03-2011, 09:38 AM
Presented by:
Vidya Reddy Thota
[attachment=11290]
Mobile Application Development with Android
Introduction to Android
Open Software platform for Mobile development.
– A complete stack – OS, Middle ware, Applications.
– Open Source Libraries.
– Software Development Kit.
– An Open Handset Alliance (OHA) project.
– Initially developed by Android Inc., Later purchased by Google.
– Open Source under the Apache2 license.
– About Android
• Android is a software platform and operating system mainly for mobile devices based on the Linux operating system.
• It allows developers to write managed application code in Java language that utilizes Google-developed Java libraries.
• Google has made most of the Android platform available under the Apache free-software and Open Source license, in Oct 2008.
Android Features
• Application Framework
• Dalvik virtual machine
• Integrated (webkit) browser
• 2D and 3D graphics APIs with HW
• SQLite
• Video and audio codecs
• Bluetooth, EDGE, 3G, and WiFi
• Camera, GPS, compass, and accelerometer
• Rich Development environment
Architecture
• Android Platform
• Base platform
• Linux 2.6.25 Kernel
• Native Libraries
• Libc, Webkit, etc.
• Dalvik VM
• Register-based VM
• Runs dex byte code
Applications
• Developed in Java
• Runs on Dalvik VM
• The Linux Kernel
• The Linux kernel is the base of the Software Stack.
• Android relies on Linux version 2.6 for core system such as security, memory management, process management, network stack, and driver model.
• The kernel also acts as an abstraction layer between the hardware and the rest of the software stack.
Android and Linux
• Android differs from the typical GNU/Linux in that it adopts only the Linux kernel, not everything.
• The first process ‘init’ transfers to Android’s own application environment.
• There is no shell by default, except using adb.
• BSD libc is used instead of glibc or uClobc.
• As a result, it is called Android/Linux, not GNU/Linux.
Android Runtime
• Provide most of the functionality available in the core libraries of the Java programming language.
• 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.
Android Runtime
• The Dalvik VM executes files in the Dalvik Executable (.dex) format ( binary code ) which is optimized for minimal memory footprint.
• The VM is registry based, and runs classes compiled by a Java language compiler that have been transformed into .dex format by the included ‘dx’ tool.
• It relies on the Linux kernel for underlying functionality such as threading and low level memory management.
The First Complete Android Phone
• T- mobile G1
• Qualcomm MSM7201A,528 MHz
• ROM : 256 MB, RAM : 192 MB
• Touch Screen ( 320 x 480 )
• Real Web browsing capabilities
• 3.2 MP camera , QWERTY key board
• 3G WCDMA, Quad band GSM , WiFi, Bluetooth 2.0
Development Tools for Android Applications
• Currently supported development platforms include x86 based computers running Linux, Mac 0S X 10.4.8 or later, Windows XP, Vista, 7
• The Android SDK includes a comprehensive set of development tools, including a debugger, libraries, a handset emulator (QEMU), documentations, Sample code and tutorials.
• http://developer.androidsdk/
• Requirements also include Java Development Kit.
• The officially supported integrated development environment is Eclipse (3.3 or 3.4) with the Android Development Tools (ADT) plugin.
• http://eclipsedownloads/
• Eclipse Android Plugin
• https://dl-ssl.googleandroid/eclipse/
• Android Developer’s Website
• http://developer.androidindex/html
Android SDK
• ADT : Android Development Tool, an Eclipse Plugin.
• Two Debuggers.
• Adb : Android Debug Bridge
• Ddms : Dalvik Debug Monitor Server.
• Aapk : Android Application Package Tool
• All resources are bundled into an archive, called apk file.
• Dx : Java byte code to Dalvik executable translator.
• Android Emulator : QEMU
Android Application Fundamentals
• Compiled Java code, data and resources are bundled into an android package(*.apk)
• Each Android application lives in its own world
• Own Linux process
• Each process has own Java VM
• Each application has own unique Linux user ID
Application Components
• Activities
• Visual User Interface
• Intent and Intent Filter
• Simple message objects
• Services
• Runs in the background
• Broadcast Receivers
• Receive and react to broadcast announcements
• Content Providers
• Make application data available
Activity
• Displays a user interface component and responds to system/user.
• When an applications has a user interface, it contains one or more ‘Activities’.
• An existing ‘Activity’ can be replaced with a new one that fulfill the same intent.
• Each ‘Activity’ can be invoked from other applications.
• Adding a new ‘Activity’ in an Android project.
• The new Java class must extend the framework ‘Activity’ class.
• Created ‘Activity’ must be defined into the application’s Manifest.xml.
• Life Cycle of an Activity
• Life Cycle not directly controlled by application.
• System can kill an application to free up memory.
• Control through ‘onCreate (), onPause (), onStop () methods.
Intents/Intent Filters
• Provide a late runtime binding between the code in different applications.
• Intents: Simple message objects that represent an intention to do something.
• Intent Filters: A declaration of capacity and interest in offering assistance to those in need.
• An ‘intent’ is made up of a number of pieces of information describing the action or the service.
• 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.
• Intent newActivity =new Intent(MyActivity.this, Other Activity.class);
startActivity(newActivity) ;
Services
• Similar to activities , but without UI
• For long running background tasks
• Framework ‘Service’ class must be extended
• Core Services
– Activity Manager
– Package Manager
– Window Manager
– Resource Manager
– Content Providers
– View System
Example :
StartService(new Intent( this_activity.this, some_service.class));