You are on page 1of 47

Getting started with Android

Introduction to android application development


session by By @AlSayedGamal #Nozom_android

Saturday, May 12, 12

Agenda
Whats Android. The stack. android Roadmap. Getting your hands dirty.

Saturday, May 12, 12

1.Whats Android and whats not?


Android is software stack for mobile devices that includes an operating system, middleware and kep applications. Its NOT a handset name. Its NOT J2ME. Its NOT Google reply to iPhone.

Saturday, May 12, 12

History
Aug 2005 Google acquired Android. Nov 2007 OHA* announced that Android SDK is available. Sept 2008 HTC and T-Mobile announced G1 Oct 2008 Android SDK 1.0 Android Market goes live G1 is available in the retail store.

*OHA is (Open Handset Alliance) including top OEM and operators {Motorolla, intel, htc, T-Mobile, Samsung, LG, Google, etc..
Saturday, May 12, 12

Software

t Manufacturers

OHA Open Handset Manufacturers Handset Alliance


Mobile Operators
Handset Manufacturers

Software Mobile Operators

Semiconductor

Software Software Commercialization

Mobile Operators
Semi-conductors operator
Semiconductor

Commercialization

Commercialization Handset Manufacturers

Semiconductor Mobile Operators Commercialization


Saturday, May 12, 12

Software Commercialization Software


OEM

Dec 2011

Saturday, May 12, 12

OS Shares worldwide*
Android iOS Bada Others Symbian RIM Microsoft

*According to Gartner Nov 2011


Saturday, May 12, 12

OS Shares worldwide*
1% 1% 2%
Android iOS Bada Others Symbian RIM Microsoft

11% 15%

52%

17%

*According to Gartner Nov 2011


Saturday, May 12, 12

Devices (not telephones)


Cellphones Tablets TV more

Saturday, May 12, 12

2.The stack
What to expect from android.

Saturday, May 12, 12

2.The stack.
Android is based on the almighty linux kernel. Android comes with great libraries and APIs for your special hardware to make full use of you device. Android has rich development tool set including emulator, debugging tools, GUI composer,etc.. Android is ready for i18n. The DVM is young VM yet its optimized to the linux kernel.

Saturday, May 12, 12

Technical prerequisites for Android development.


Java* = Java SE - Swing - AWT - reection + some API(s). HTML5 is an option (nice option if you are going cross platform). Others (nice for RAD and cross platform).

*We are interested in that option today


Saturday, May 12, 12

Android the platform


Android the OS is the largest part but its not everything. Android emulator and AVD. DVM (Dalvik Virtual Machine). ADB (Android Debug Bridge).

Saturday, May 12, 12

Closer look

Saturday, May 12, 12

Closer look

Saturday, May 12, 12

Android internals

Saturday, May 12, 12

Android internals

Linux Kernel
Display Driver USB Driver Camera Driver Keypad Driver Bluetooth Driver WiFi Driver Flash Memory Driver Audio Drivers Binder (IPC) Driver Power Management

Saturday, May 12, 12

Android internals

Libraries
Surface Manager OpenGL | ES SGL Media Framework FreeType SSL SQLite WebKit libc

Linux Kernel
Display Driver USB Driver Camera Driver Keypad Driver Bluetooth Driver WiFi Driver Flash Memory Driver Audio Drivers Binder (IPC) Driver Power Management

Saturday, May 12, 12

Android internals

Libraries
Surface Manager OpenGL | ES SGL Media Framework FreeType SSL SQLite WebKit libc

Android Runtime
Core Libraries Dalvik Virtual Machine

Linux Kernel
Display Driver USB Driver Camera Driver Keypad Driver Bluetooth Driver WiFi Driver Flash Memory Driver Audio Drivers Binder (IPC) Driver Power Management

Saturday, May 12, 12

Android internals
Application Framework
Activity Manager Package Manager Window Manager Telephony Manager Content Providers Resource Manager View System Location Manager Notication Manager GTalk Service

Libraries
Surface Manager OpenGL | ES SGL Media Framework FreeType SSL SQLite WebKit libc

Android Runtime
Core Libraries Dalvik Virtual Machine

Linux Kernel
Display Driver USB Driver Camera Driver Keypad Driver Bluetooth Driver WiFi Driver Flash Memory Driver Audio Drivers Binder (IPC) Driver Power Management

Saturday, May 12, 12

Android internals
Applications
Home Contacts Phone Browser

...

Application Framework
Activity Manager Package Manager Window Manager Telephony Manager Content Providers Resource Manager View System Location Manager Notication Manager GTalk Service

Libraries
Surface Manager OpenGL | ES SGL Media Framework FreeType SSL SQLite WebKit libc

Android Runtime
Core Libraries Dalvik Virtual Machine

Linux Kernel
Display Driver USB Driver Camera Driver Keypad Driver Bluetooth Driver WiFi Driver Flash Memory Driver Audio Drivers Binder (IPC) Driver Power Management

Saturday, May 12, 12

Everything is an application

Your app is rst class citizen


Saturday, May 12, 12

API levels and Android versions.


You must have heard about Ice cream sandwich. API levels 1->14 Android versions 1.x.x -> 4.x.x The capabilities vs. popularity compromise. Backward compatibility. A-[I]-Z.

Saturday, May 12, 12

Android development tools


Eclipse ADT plugin DDMS AVD more..

Saturday, May 12, 12

3.android Roadmap
Milestones in any android developer life.

Saturday, May 12, 12

Rules are made to break in.


Installation and conguration Activity and Intent Layouts Background Services Broadcast receivers. Content providers. Shared preferences, sqlite database and le storage. Internet and C2DM. Geolocation apps.

Saturday, May 12, 12

public class Activity extends ApplicationContext { protected void onCreate(Bundle savedInstanceState); protected void onStart(); protected void onRestart(); protected void onResume(); protected void onPause(); protected void onStop(); protected void onDestroy(); }

1.Activity

Saturday, May 12, 12

1.Activity
Activity class is the main building block in any android application. Basically every screen in any android app is an activity. Every activity may deal with one or more layout. Its essential to know the Activity lifecycle*. onCreate, onPause, onRestart, onResume methods.

*Template design pattern.[2]


Saturday, May 12, 12

Android Activity lifecycle

Image source: http://developer.android.com/images/activity_lifecycle.png


Saturday, May 12, 12

2.Intent

Saturday, May 12, 12

2.Intent
Intent is the message passing system in Android. Is used to message {activities, services and broadcast receivers} Its used to call system services as well as your app activities.* Intents can contain extra data and this is how we transfer data between activities,apps,services,etc.. Application dependency issues.
*Thats why your app is 1st class citizen.
Saturday, May 12, 12

Intent lters
<intent-filter . . . > <action android:name="code android.intent.action.MAIN" /> <category android:name="code android.intent.category.LAUNCHER" /> </intent-filter>

When android intents meet Activities. Action Category Ex.The application launcher scenario.

Saturday, May 12, 12

3.AndroidManifest.xml

Saturday, May 12, 12

3.manifest.xml
Each application has one manifest le Its app conguration le in short. ADT interface shows what do you expect from it. Warning: Dont forget to dene your activies there.

*Thats why your app is 1st class citizen.


Saturday, May 12, 12

4.Getting your hands dirty


Lets practice what we have learnt so far.

Saturday, May 12, 12

1.Installation and conguration


Eclipse, ADT and the SDK

Saturday, May 12, 12

Application Directory Structure


src : your code lives here. res : your layout and resource les are here. gen: by name its generated content mostly it maps to layouts and resources. bin : output les and APK (Android Package) executable le. AndroidManifest.xml: general conguration le.

Saturday, May 12, 12

The Android Package

meet the

Saturday, May 12, 12

The Android Package

meet the

APK

Saturday, May 12, 12

The APK
le.apk
|--AndroidManifest.xml |-- META-INF | |-- CERT.RSA | |-- CERT.SF | `-- MANIFEST.MF |-- classes.dex |-- res | |-- drawable | | `-- icon.png | `-- layout | `-- main.xml `-- resources.arsc

Saturday, May 12, 12

App1: todo list


In order to add a new task as a user, I should be able to supply task name in a textbox and hit save. In order to conrm saving the task I should see a success message. Task should be added to a list of checkboxes. In order to mark a task completed I should check the check box by the task name.

Saturday, May 12, 12

App2: SuperComm
App is basically 3 buttons using which user can access dialer, SMS app, and web. App is containing a textbox containing the number/url Im trying to call,SMS or browse.

Saturday, May 12, 12

Debugging your app.


DDMS. adb. le browser. Playing with the emulator.

Saturday, May 12, 12

References

http://developer.android.com. http://en.wikipedia.org/wiki/Template_method_pattern http://google.com

Saturday, May 12, 12

Summary
Android is now and future. Its opensource and fun. Android stack and rich development tools. Everything is an application and your application is 1st class citizen. Android application development terminology. Android development road map.

Saturday, May 12, 12

Questions & Answers

Saturday, May 12, 12

Thank you!

Saturday, May 12, 12

You might also like