google android @ alphacsp's javaedge
DESCRIPTION
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.TRANSCRIPT
![Page 1: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/1.jpg)
Title
Sub Title
Nadav
Wiener
Google Andro
id
Breaking The
Mobile Mo
ld
Decem
ber 18
th 2008
![Page 2: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/2.jpg)
Hello Android
2
![Page 3: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/3.jpg)
Target Audience
• Mobile software developers
• People shopping for a phone in 2009
3
![Page 4: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/4.jpg)
Agenda
• Hello Android
• Architecture Overview, Features and
Components
• Android Software Development
• Live Demo
4
![Page 5: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/5.jpg)
Hello Android
5
• Android is a platform for mobile
computing
• Android is Linux based
• But development is in Java
![Page 6: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/6.jpg)
Hello Android
6
• 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
![Page 7: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/7.jpg)
Hello Android::Timeline
As published by Google
7
![Page 8: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/8.jpg)
Hello Android::Timeline
As published by Google
![Page 9: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/9.jpg)
Hello Android::Timeline
As published by Google
• We’ll have a look at
some of the winners
later on
![Page 10: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/10.jpg)
Hello Android::Timeline
As published by Google
• Only free applications for
now
• Eventually, Google will
take a 30% cut
![Page 11: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/11.jpg)
Hello Android::Timeline
As published by Google
![Page 12: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/12.jpg)
Hello Android::Timeline
As published by Google
![Page 13: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/13.jpg)
Hello Android::Timeline
As published by Google
![Page 14: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/14.jpg)
Hello Android::Devices
14
• HTC G1, Lenovo OPhone (expected),
Kogan Agora
![Page 15: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/15.jpg)
Hello Android::ADC
• The Android Developer Challenge
• 10,000,000$ in prizes
15
![Page 16: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/16.jpg)
Hello Android::ADC
• ADC I concluded:
• 5M$ in prizes
• Over 1,700 submissions
• Announcement regarding
ADC II is expected soon16
![Page 17: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/17.jpg)
Hello Android::ADC Winners & Market
• Wikitude (Philipp Breuce)
• Wikipedia overlaid on camera view
17
![Page 18: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/18.jpg)
Hello Android::ADC Winners & Market
• BreadCrumbz (Amos Yoffe)
• Navigate using maps and pictures (like Myst)
18
![Page 19: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/19.jpg)
Hello Android::ADC Winners & Market
• Amazon MP3 for Android
• Preinstalled on HTC G1 phones
19
![Page 20: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/20.jpg)
Hello Android::ADC Winners & Market
• Compare Everywhere (Jeffrey Sharkey)
• Capture barcodes, search for better deals nearby
20
![Page 21: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/21.jpg)
Agenda
• Hello Android
• Architecture Overview, Features and
Components
• Android Software Development
• Live Demo
21
![Page 22: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/22.jpg)
Architecture Overview
22
Linux Kernel
Device Drivers
Inter Process Comms. Security
Power Management
Native Libraries
Media Framework
SQLiteDatabase
WebKit Browser
Graphics Libraries
Android Runtime Apache Harmony Dalvik VM
Android Application Framework
ActivitiesPackage
ManagementContent ProvidersViews Services
Applications
•Implement and leverage framework concepts•Use framework components and services
![Page 23: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/23.jpg)
Architecture Overview
• Let’s examine some of these boxes,
beginning with Linux:
Linux Kernel
![Page 24: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/24.jpg)
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
![Page 25: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/25.jpg)
• Native libraries provide functionality
Native Libraries
Linux Kernel
![Page 26: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/26.jpg)
Architecture Overview
• WebKit
• Same browser engineused in IPhone,Google Chrome,Safari
• Strong performer
• Memory efficient
• Good standards support
26
![Page 27: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/27.jpg)
Architecture Overview
• Location Services & Mapping
• Google Maps
• Street view
• GPS
• Trigger proximityalerts
![Page 28: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/28.jpg)
Architecture Overview
• Graphics
• SGL – 2D scalable graphics
• OpenGL ES
• Surface Manager composes surfaces together
28
![Page 29: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/29.jpg)
Architecture Overview
• Media Framework
• Player and codecs
• SQLite
• Lightweight RDBMS also on IPhone
• ... and Telephony too!
29
![Page 30: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/30.jpg)
Architecture Overview::
Android Runtime
Moving on to the “Java” runtime
environment:
30
Linux Kernel
Native Libraries Android Runtime
![Page 31: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/31.jpg)
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
![Page 32: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/32.jpg)
Architecture Overview::
Dalvik Virtual Machine
32
• You still get to develop in
Java
• Excellent learning curve
• What, no JVM!?
![Page 33: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/33.jpg)
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
![Page 34: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/34.jpg)
Architecture Overview
34
Linux Kernel
Device Drivers
Inter Process Comms. Security
Power Management
Native Libraries
Media Framework
SQLiteDatabase
WebKit Browser
Graphics Libraries
Android Runtime Apache Harmony Dalvik VM
Android Application Framework
ActivitiesPackage
ManagementContent ProvidersViews Services
Applications
•Implement and leverage framework concepts•Use framework components and services
![Page 35: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/35.jpg)
Agenda
• Hello Android
• Architecture Overview, Features and
Components
• Android Software Development
• Live Demo
35
![Page 36: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/36.jpg)
Android Application Framework
• Building Blocks
• Application Model
• UI Perspective
36
![Page 37: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/37.jpg)
Building Blocks
• Four building blocks
• Activities and Intents
• Broadcast Receivers
• Services
• Content Providers
37
![Page 38: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/38.jpg)
Activities and Intents
Activities
Android documentation states:
• “An activity is a single, focused thing
that the user can do.”
38
![Page 39: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/39.jpg)
Activities and Intents
• This how an activity will look like:
39
![Page 40: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/40.jpg)
Activities and Intents
• Well, actually: “An activity is usually a
single screen in your application.”
40
![Page 41: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/41.jpg)
Activities and Intents
• Activities communicate with each other
using Intents
41
? !
new Intent(Intent.ACTION_PICK, new Uri("content://contacts"))
• The Intent is resolved to another
Activity, by matching it against an
Intent Filter.
new Intent(Intent.ACTION_DIAL, new Uri(“tel:555-1234"))
new Intent(Intent.ACTION_VIEW, new Uri(“geo:38.8995,-
77.0364"))
![Page 42: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/42.jpg)
Activities and Intents
• Intents convey
• Data
• Action
•
• and Categories
42
This is how
Intent Filters
match Intents
that are valid
for the Activity
![Page 43: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/43.jpg)
Activities and Intents
• Activities are managed on
a stack
43
• Once you go back they pop!
![Page 44: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/44.jpg)
Activities and Intents
• Activities have a life cycle
44
NewActivity
Stopped Activity
Paused Activity
Running...
Processes with non-running Activities may be killed to free resources
![Page 45: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/45.jpg)
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 notifications45
![Page 46: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/46.jpg)
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 process46
![Page 47: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/47.jpg)
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
![Page 48: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/48.jpg)
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
![Page 49: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/49.jpg)
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
![Page 50: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/50.jpg)
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
![Page 51: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/51.jpg)
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
![Page 52: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/52.jpg)
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
![Page 53: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/53.jpg)
Android Software Development
53
package com.example.android.helloactivity; //... /** * A minimal "Hello, World!" 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); } }
![Page 54: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/54.jpg)
Android Software Development
54
<EditText
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="18sp"
android:autoText="true"
android:capitalize="sentences"
android:text="hello, world!" />
![Page 55: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/55.jpg)
Android Software Development
55
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.helloactivity">
<application android:label="Hello, Activity!">
<activity android:name="HelloActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
![Page 56: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/56.jpg)
Android Software Development
• After build and deployment to the
emulator:
56
![Page 57: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/57.jpg)
UI Perspective
• Android UI lends itself to a clear flow
between simple screens
57
![Page 58: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/58.jpg)
UI Perspective
• Rich clients, on the other hand…
58
… Don’t translate that well.
![Page 59: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/59.jpg)
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
![Page 60: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/60.jpg)
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
![Page 61: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/61.jpg)
References
• Android homepage:
http://code.google.com/android/index.html
• Open Handset Alliance:
http://www.openhandsetalliance.com/
• Android Market:
http://www.android.com/market/
• Android documentation: http://code.google.com/android/documentation.html
• Android open source project:
http://source.android.com/
61
![Page 62: Google Android @ AlphaCSP's JavaEdge](https://reader034.vdocuments.mx/reader034/viewer/2022042700/55499124b4c905b96a8b548a/html5/thumbnails/62.jpg)
Apps for Android:http://code.google.com/p/apps-for-android
62
DemoDemo