Android Overview

24
Date, time, etc.

description

Theme day presentation @Futurice

Transcript of Android Overview

Page 1: Android Overview

Date, time, etc.

Page 2: Android Overview

Date, time, etc.

What is Android?

• Android is an open-source mobile platform

• Source code available under the Apache license

• http://source.android.com/

• Roadmap available: http://source.android.com/roadmap

• Google apps not open source (Market, Gmail, Maps)

• Built on Linux

• Offers full stack: OS, middleware, applications, developer

APIs and tools, QEMU-based emulator

• Developed by the Open Handset Alliance (OHA)

• Includes companies such as Broadcom, Google, HTC, Intel, LG,

Marvell, Motorola, Nvidia, Quallcom, Samsung, Sprint, T-Mobile, TI

• Strongly driven by Google

Page 3: Android Overview

Date, time, etc.

So why is Android interesting

• Modern mobile OS that could rival iPhone OS

• Many OEMs

• Still very young but lots of potential

• Platform is developing

• Just starting to get momentum

• Easy to get started with development

• Ready and working store solution

Page 4: Android Overview

Date, time, etc.

Page 5: Android Overview

Date, time, etc.

Android timeline

• 2005/07 Google acquires Android, Inc.

• 2007/11 Android is announced by OHA

• Early look SDK made available strait away

• 2008/08 Android market announced

• 2008/09 First Android device announced: T-Mobile G1 (HTC Dream)

• Android SDK 1.0 announced the same day

• 2008/10 Source code released to Android Open Source Project

• Android Market opened. Free apps only

• 2009/02 Android 1.1 released

• Paid apps to UK and US Markets

• 2009/04 Android 1.5 ”Cupcake” released

• 2009/06 Android NDK released.

• 2009/09 Android 1.6 ”Donut” released

Page 6: Android Overview

Date, time, etc.

Android devices

• HTC has multiple models:

• HTC Dream, 1st ever Android device

• HTC Magic

• HTC Hero

• HTC Tattoo

• ~15 devices on market, and more coming all the time

• HTC, Motorola, LG, Samsung, Philips, Huawei, Lenovo and even

Dell

• Some manufacturers create their own UI layer, e.g. Motorola

MOTOBLUR and HTC SenseUI

Page 7: Android Overview

Date, time, etc.

Developing for Android

• Easy to get started

• SDK + Eclipse plugin (ADT).

• On-device debugging

• Plenty of documentation: http://developer.android.com/

• OpenIntents-project: http://www.openintents.org/en/

• Applications written in Java

• Not JME or proper JSE. Java language syntax

• Core Android libraries provide most of the functionality in the core

Java libraries as well as additional Android-specific libraries

• NDK enables compiling native code to be used via Java Native

Interface (JNI)

• All application are equal

• You can even replace the dialer app if you want to

Page 8: Android Overview

Date, time, etc.

Android Software Stack

Page 9: Android Overview

Date, time, etc.

Dalvik VM

• Register based virtual machine

• As opposed to normal stack based VMs

• Optimized to ensure that a device can run multiple instances

efficiently. More info at http://www.dalvikvm.com/ and

http://sites.google.com/site/io/dalvik-vm-internals

• Uses own bytecode not Java bytecode

• No JIT

• Android programs are compiled into Dalvik executable files (.dex)

which are then zipped into Android packages (.apk).

• Dex-files are used to ensure minimal memory footprint.

• Uncompressed dex-file is usually still smaller than the same Java code

as compressed jar-file.

Page 10: Android Overview

Date, time, etc.

Android application framework

• Framework services

• Activity manager

• Views

• Notification manager

• Content providers

• Resource manager

• Lots of APIs: telephony, media, sensors, location, WebKit-

based browser, Google Maps, P2P & Google Talk,home

screen widgets,OpenGL, FreeType,SQLite to name a few

Page 11: Android Overview

Date, time, etc.

Main building blocks

• Activities

• Visible screen of the application

• Services

• Background services

• Content providers

• Share data between activities and applications

• Intents

• Activate services and components

• Broadcast receivers

• Received and react to broadcasted events

• Resources

• Support different localizations and form factors easily

Page 12: Android Overview

Date, time, etc.

Activity

• Foreground activity is a visible screen in the application

• Handles user interaction and feedback

• Android applications have no exit. Platform handles the

lifecycle.

• Developer takes care of• onCreate

• onStart

• onResume

• Running

• onPause

• onStop

• onRestart

• onDestroy

Page 13: Android Overview

Date, time, etc.

Page 14: Android Overview

Date, time, etc.

Service

• Used for background processing for other activities

• Runs still on the main Activity’s thread

• Need to separate to own thread if needed

• Communication using e.g. Handlers if in separate threads

• Lifecycle differs from Activity

• Entire lifecycle vs active lifecycle

• onCreate, onStart, onDestroy or

• onCreate, onBind, onUnbind, (onRebind), onDestroy

• According to starting mechanism.

Page 15: Android Overview

Date, time, etc.

Service lifecycle

Page 16: Android Overview

Date, time, etc.

Content providers

• Store and share data between activities and services

• Most content providers use SQLite as the data store

• Usage via ContentResolvers and Content URIs:

• Single row: content://com.futurice.fututwit/tweets/3815526750

• All rows: content://com.futurice.fututwit/tweets/

Page 17: Android Overview

Date, time, etc.

Intents

• Intents are used to activate other activities or services

• You specify your intent: ”I want to make a phone call to

number 555 2368”

• Intent call = new Intent(Intent.ACTION_DIAL, Uri.parse(tel:555-

2368));

• startActivity(call)

• Activities mapped to intent with Intent filters in the manifext

xml-file

• You can provide your own replacements even to platform’s

own intent handlers, e.g. Dialer

• Promotes loose coupling

Page 18: Android Overview

Date, time, etc.

Broadcast receivers

• Used to listen to events sent by activities or services

• Declared in the manifest as Intent Filter

• Extend BroadcastReceiver

Page 19: Android Overview

Date, time, etc.

User interface

• Is composed of Views and ViewGroups

• Uses layouts

• Layouts are ViewGroups

• Lots of ready-made Views

• ListView, TextView, EditText, Buttons, all the usual suspects

• Also ready made components to include maps or a browser control

in to your application. OpenGL ES can be used as well.

• Easy to create custom Views

Page 20: Android Overview

Date, time, etc.

User interface continued

• Declarative approach using XML preferred over in-code

• I18N and L10N is simple using XML resources

• ResourceManager matches with dir structure according to

precedence

• Drawable-fr

• Drawable-en-notouch

• Drawable-en-port-92dpi

• 9-Patch bitmaps

• No SVG support!

• Animations:

• Tweened, declared in XML

• Frame-by-frame

Page 21: Android Overview

Date, time, etc.

Application data and security

• Underlying Linux user account created for each app

• Security based on app permissions

• Declarative permissions

• Signed by developer’s certificate

• User approves permissions when installing

• Applications are sandboxed

• Use Content providers to share data

• Store light weight preferences in app dir

• For more data SQLite

Page 22: Android Overview

Date, time, etc.

Android Market

• Since October 2008

• Started with free apps only

• In February 2009 paid apps were introduced in UK and US

Markets.

• Payment via Google Checkout

• Paid apps available in 10 countries (not Finland)

• $25 registration fee for developers

• 70% to developer

• Price range: free - $200 (No I Am Rich apps)

• 24h money back guarantee!

• Ratings, upgrades, stats

Page 23: Android Overview

Date, time, etc.

Thank you

Page 24: Android Overview

Date, time, etc.

References

• Images courtesy of

• http://developer.android.com/

• http://bit.ly/JXX97