Google Android, An hybrid software stack for mobile devices -- part Linux, part Java -- boots Linux and provides key components natively, yet for all intents and purposes aims for Java application development. While maintaining commitment to Java, Google has broken the mobile mold by delivering a radically different virtual machine and a brand new application framework. Google is pushing for a strong mobile presence, prompting the industry to adapt. You are invited to have a peek inside Android, see what makes it tick, and examine software migration and development options for the platform.
3. Target Audience
• Mobile software developers
• People shopping for a phone in 2009
3
4. Agenda
• Hello Android
• Architecture Overview, Features and
Components
• Android Software Development
• Live Demo
4
5. Hello Android
• Android is a platform for mobile
computing
• Android is Linux based
• But development is in
Java
5
6. Hello Android
• Why did Google make Android?
• IPhone does not support Java
• JavaME’s CLDC+MIDlets are getting
old
• Leaves lots of mobile developers in
search of a platform
• Profit – ads, market
• Clean break from J2ME
6
21. Agenda
• Hello Android
• Architecture Overview, Features and
Components
• Android Software Development
• Live Demo
21
22. Architecture Overview
Applications
•Implement and leverage framework concepts
•Use framework components and services
Android Application Framework
Package Content
Views Activities Services Management Providers
Native Libraries Android Runtime Apache Harmony Dalvik VM
Graphics
Media WebKit SQLite
Libraries
Framework Browser Database
Linux Kernel
Inter Process Power
Device
Comms.
Security Management
Drivers
22
23. Architecture Overview
• Let’s examine some of these boxes,
beginning with Linux:
Linux Kernel
24. Architecture Overview
• From Linux Android gains:
• A stable common base for Dalvik
applications
• Fine grained power management
• Unique user per bundle – sandboxing
• Much more…
24
26. Architecture Overview
• WebKit
• Same browser engine
used in IPhone,
Google Chrome,
Safari
• Strong performer
• Memory efficient
• Good standards support
26
27. Architecture Overview
• Location Services & Mapping
• Google Maps
• Street view
• GPS
• Trigger proximity
alerts
31. Architecture Overview::
Dalvik Virtual Machine
• Java has a stack based VM
• Dalvik is a register based VM
• Better interpreter performance
• No JIT
• Bottom line:
• Lower throughput
• Better startup & responsiveness
31
33. Architecture Overview::Zygote
• Quick Dalvik process startup is
essential for good responsiveness
• During boot, Android creates a fully
bootstrapped Dalvik process
• Sends it to sleep
• Forks it on demand
• Forks are copy-on-write
• Near instantaneous startup!
33
34. Architecture Overview
Applications
•Implement and leverage framework concepts
•Use framework components and services
Android Application Framework
Package Content
Views Activities Services Management Providers
Native Libraries Android Runtime Apache Harmony Dalvik VM
Graphics
Media WebKit SQLite
Libraries
Framework Browser Database
Linux Kernel
Inter Process Power
Device
Comms.
Security Management
Drivers
34
35. Agenda
• Hello Android
• Architecture Overview, Features and
Components
• Android Software Development
• Live Demo
35
40. Activities and Intents
• Well, actually: “An activity is usually a
single screen in your application.”
40
41. Activities and Intents
• Activities communicate with each other
using Intents
new Intent(
? !
Intent.ACTION_VIEW,
Intent.ACTION_DIAL,
Intent.ACTION_PICK,
new Uri(quot;content://contactsquot;))
Uri(“geo:38.8995,-
Uri(“tel:555-1234quot;))
77.0364quot;))
• The Intent is resolved to another
Activity, by matching it against an
Intent Filter.
41
42. Activities and Intents
• Intents convey
• Data
This is how
Intent Filters
match Intents
that are valid
• Action
for the Activity
•
• and Categories
42
43. Activities and Intents
• Activities are managed on
a stack
• Once you go back they
pop!
43
44. Activities and Intents
• Activities have a life cycle
New Stopped Paused
Running...
Activity Activity Activity
Processes with non-
running Activities may be
killed to free resources
44
45. Broadcast Receivers
• Listens for Intents
• Incoming call
• Network availability changes
• Alarms
• Application doesn't have to be running
once a Receiver is registered
• Does not display UI
• May use notifications 45
46. Services
• Services perform long running actions
• i.e. Play music, factor primary numbers
• Services are defined via AIDL
• Yet another “Interface Definition
Language”
• Service lifecycle: manual or automatic
• Can be run either in-process or
in another process
46
47. Content Providers
• Android likes to expose content in a
RESTful manner
• All content items have a unique URI
• Goes really well with Activity history
• Content Providers are used for CRUD
operations over arbitrary content
repositories
47
48. Content Providers
• The interface has a strong relational
feel
• Hard to adapt to POJO backends like
DB4O and Perst
• Despite looking relational, the interface
encourages static joins
• Data returned should have a uniform
shape
48
49. Application Model
• Android Package (.apk)
• Compiled code & resources
• Manifest
• Must be signed (like jar)
• Task
• “perceived” application
• May span activities across several
packages and processes 49
50. UI Perspective
• Views
• From very simple:
• EditText, CheckBox, Button, Radio
• To more specialized:
• DatePicker, AutoComplete
• ViewGroups (layout)
• Relative, Table, Linear, …
• Web, Video, Map, Gallery... 50
51. UI Perspective
• Sometimes the border between Views
and Activities isn't clear
• MapView
• MapActivity
• Choose MapActivity for a mashup
• Choose MapView for your own Activity
51
52. Android Software Development
• Let's have a look at a “hello world”
sample provided by the SDK:
• Activity source file
• Layout file
• Android Manifest
52
53. Android Software Development
package com.example.android.helloactivity;
//...
/**
* A minimal quot;Hello, World!quot; application.
*/
public class HelloActivity extends Activity {
/**
* Called with the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the layout for this activity. You can find it
// in res/layout/hello_activity.xml
setContentView(R.layout.hello_activity);
}
}
53
57. UI Perspective
• Android UI lends itself to a clear flow
between simple screens
57
58. UI Perspective
• Rich clients, on the other hand…
… Don’t translate that well.
58
59. Porting Scenarios
• Opera
• Opera Mini uses
• Jetty has been ported
• local web applications
• Apache Felix has been ported
• OSGi bundles
• Alef Arendsen’s session covers OSGi in
Spring 59
60. Tool Support
• Android SDK and Eclipse plugin:
http://code.google.com/android/
• IntelliJ IDEA plugin is available here:
http://code.google.com/p/idea-android/
• SDK can create IDEA project files
• NetBeans plugin available here:
http://kenai.com/projects/nbandroid/
• DroidDraw is an Android UI builder:
http://www.droiddraw.org/ 60