Title: Android
1The Android GUI Framework Android experience
dayDecember 2008
Markus Pilz Peter Wlodarczak
2Agenda
1. Introduction
2. Anatomy
3. A real word example
4. Life cycle
5. Trends
6. Findings
3Why Android
- Android was designed as a platform for software
development
4Android Platform
5Anatomy I
- GUI is fully written in Java
6Anatomy II
- Intent, IntentFilter, IntertReceiver
7Anatomy III
- Native calls (not officially)?
8A real word example I
- If you are in a country where no one understands
your language
- You have your mobile phone always with you
- No additional device needed
9A real word example II
- Uses the Google translator
- Uses XMPP for data transmission
- Can be extended with new languages
10A real word example III
Lets see it
11A real word example IV
- Used Eclipse for development
- ANT script and make for build
- Uses persistence of user data
- Uses touch screen and keyboard input
12A real word example V
The AndroidManifest.xml
ltmanifest xmlnsandroid"http//schemas.android.c
om/apk/res/android" package"com.greenliff.tra
nslator"gt ltapplication androidicon"_at_drawable
/logo"gt ltactivity androidlabel"_at_string/s
ettings" androidname"Settings"gt
ltintent-filtergt ltaction
androidname"android.intent.action.MAIN" /gt
lt/intent-filtergt lt/activitygt
ltactivity androidlabel"_at_string/app_name"
androidname"Translate"gt
ltintent-filtergt ltaction
androidname"android.intent.action.MAIN" /gt
ltcategory androidname"android.intent.
category.LAUNCHER" /gt
lt/intent-filtergt lt/activitygt
ltactivity androidlabel"_at_string/ocr"
androidname"OCR"gt ltintent-filtergt
ltaction androidname"android.intent
.action.MAIN" /gt lt/intent-filtergt
lt/activitygt lt/applicationgt lt/manifestgt
13A real word example V
The AndroidManifest.xml
ltmanifest xmlnsandroid"http//schemas.android.c
om/apk/res/android" package"com.greenliff.tra
nslator"gt ltapplication androidicon"_at_drawable
/logo"gt ltactivity androidlabel"_at_string/s
ettings" androidname"Settings"gt
ltintent-filtergt ltaction
androidname"android.intent.action.MAIN" /gt
lt/intent-filtergt lt/activitygt
ltactivity androidlabel"_at_string/app_name"
androidname"Translate"gt
ltintent-filtergt ltaction
androidname"android.intent.action.MAIN" /gt
ltcategory androidname"android.intent.
category.LAUNCHER" /gt
lt/intent-filtergt lt/activitygt
ltactivity androidlabel"_at_string/ocr"
androidname"OCR"gt ltintent-filtergt
ltaction androidname"android.intent
.action.MAIN" /gt lt/intent-filtergt
lt/activitygt lt/applicationgt lt/manifestgt
Activity
14A real word example V
The AndroidManifest.xml
ltmanifest xmlnsandroid"http//schemas.android.c
om/apk/res/android" package"com.greenliff.tra
nslator"gt ltapplication androidicon"_at_drawable
/logo"gt ltactivity androidlabel"_at_string/s
ettings" androidname"Settings"gt
ltintent-filtergt ltaction
androidname"android.intent.action.MAIN" /gt
lt/intent-filtergt lt/activitygt
ltactivity androidlabel"_at_string/app_name"
androidname"Translate"gt
ltintent-filtergt ltaction
androidname"android.intent.action.MAIN" /gt
ltcategory androidname"android.intent.
category.LAUNCHER" /gt
lt/intent-filtergt lt/activitygt
ltactivity androidlabel"_at_string/ocr"
androidname"OCR"gt ltintent-filtergt
ltaction androidname"android.intent
.action.MAIN" /gt lt/intent-filtergt
lt/activitygt lt/applicationgt lt/manifestgt
Activity
Launch
15A real word example VI
The AndroidManifest.xml
- Define permissions, e. g.
- ltuses-permission androidname"android.permissio
n.RECEIVE_SMS" /gt
- Give other Activities access
16A real word example VII
An XML snipped of the main Activity
ltScrollView xmlnsandroid"http//schemas.android.
com/apk/res/android" androidlayout_width"fil
l_parent" androidlayout_height"wrap_content"
androidscrollbars"vertical"gt
ltLinearLayout xmlnsandroid"http//schemas.androi
d.com/apk/res/android" androidid"_at_id/li
nLayout" androidorientation"vertical"
androidlayout_width"fill_parent"
androidlayout_height"wrap_content"gt ltTextView
androidlayout_width"fill_parent"
androidlayout_height"wrap_content"
androidbackground"_at_drawable/blue"
androidtext"_at_string/translate_to_1"/gt ltEditTex
t androidid"_at_id/toTranslate"
androidlayout_width"fill_parent"
androidlayout_height"wrap_content"
androidbackground"_at_androiddrawable/editbox
_background" androidlayout_below"_at_id/l
inLayout androidhint"Type here..." /gt .....
Text reference
17A real word example VII
An XML snipped of the main Activity
ltScrollView xmlnsandroid"http//schemas.android.
com/apk/res/android" androidlayout_width"fil
l_parent" androidlayout_height"wrap_content"
androidscrollbars"vertical"gt
ltLinearLayout xmlnsandroid"http//schemas.androi
d.com/apk/res/android" androidid"_at_id/li
nLayout" androidorientation"vertical"
androidlayout_width"fill_parent"
androidlayout_height"wrap_content"gt ltTextView
androidlayout_width"fill_parent"
androidlayout_height"wrap_content"
androidbackground"_at_drawable/blue"
androidtext"_at_string/translate_to_1"/gt ltEditTex
t androidid"_at_id/toTranslate"
androidlayout_width"fill_parent"
androidlayout_height"wrap_content"
androidbackground"_at_androiddrawable/editbox
_background" androidlayout_below"_at_id/l
inLayout androidhint"Type here..." /gt .....
Id
Text reference
18A real word example VIII
- Could also be developed purely in Java
- Not all the attributes can be defined in XML
19A real word example IX
A code snipped of the Translate Activity
_at_Override public void onCreate(Bundle
icicle) super.onCreate(icicle)
Window wp getWindow() mContext
wp.getContext() setTheme(android.R.style.
Theme_Light) setContentView(R.layout.main
) mLayout (LinearLayout)
this.findViewById(R.id.linLayout)
mToTranslate (EditText) this.findViewById(R.id.t
oTranslate) setShowLanguages()
mEnge (LinearLayout) this.findViewById(R.id
.enge) LANGUAGE_LAYOUT0 mEnge
de2en (Button) this.findViewById(R.id.de2en)
de2en.setOnClickListener(new
View.OnClickListener() public void
onClick(View view)
if(!connect())
notLoggedInAlert() else
doConnect("de2en_at_bot.talk.google.com"
) rearrange(mEnge)
) ....
20A real word example IX
A code snipped of the Translate Activity
_at_Override public void onCreate(Bundle
icicle) super.onCreate(icicle)
Window wp getWindow() mContext
wp.getContext() setTheme(android.R.style.
Theme_Light) setContentView(R.layout.main
) mLayout (LinearLayout)
this.findViewById(R.id.linLayout)
mToTranslate (EditText) this.findViewById(R.id.t
oTranslate) setShowLanguages()
mEnge (LinearLayout) this.findViewById(R.id
.enge) LANGUAGE_LAYOUT0 mEnge
de2en (Button) this.findViewById(R.id.de2en)
de2en.setOnClickListener(new
View.OnClickListener() public void
onClick(View view)
if(!connect())
notLoggedInAlert() else
doConnect("de2en_at_bot.talk.google.com"
) rearrange(mEnge)
) ....
Set layout
21A real word example IX
A code snipped of the Translate Activity
_at_Override public void onCreate(Bundle
icicle) super.onCreate(icicle)
Window wp getWindow() mContext
wp.getContext() setTheme(android.R.style.
Theme_Light) setContentView(R.layout.main
) mLayout (LinearLayout)
this.findViewById(R.id.linLayout)
mToTranslate (EditText) this.findViewById(R.id.t
oTranslate) setShowLanguages()
mEnge (LinearLayout) this.findViewById(R.id
.enge) LANGUAGE_LAYOUT0 mEnge
de2en (Button) this.findViewById(R.id.de2en)
de2en.setOnClickListener(new
View.OnClickListener() public void
onClick(View view)
if(!connect())
notLoggedInAlert() else
doConnect("de2en_at_bot.talk.google.com"
) rearrange(mEnge)
) ....
Find elements
Set layout
22A real word example IX
A code snipped of the Translate Activity
_at_Override public void onCreate(Bundle
icicle) super.onCreate(icicle)
Window wp getWindow() mContext
wp.getContext() setTheme(android.R.style.
Theme_Light) setContentView(R.layout.main
) mLayout (LinearLayout)
this.findViewById(R.id.linLayout)
mToTranslate (EditText) this.findViewById(R.id.t
oTranslate) setShowLanguages()
mEnge (LinearLayout) this.findViewById(R.id
.enge) LANGUAGE_LAYOUT0 mEnge
de2en (Button) this.findViewById(R.id.de2en)
de2en.setOnClickListener(new
View.OnClickListener() public void
onClick(View view)
if(!connect())
notLoggedInAlert() else
doConnect("de2en_at_bot.talk.google.com"
) rearrange(mEnge)
) ....
Find elements
Set layout
Add behavior
23A real word example X
Call an other Activity
_at_Override public boolean
onOptionsItemSelected(Menu.Item item)
switch (item.getId()) case 0
showLogin() break
case 1 Intent intent new
Intent(Translate.this, Settings.class)
intent.putExtras(mShownLanguages)
startSubActivity(intent, SETTINGS)
break // switch return
true
24A real word example X
Call an other Activity
_at_Override public boolean
onOptionsItemSelected(Menu.Item item)
switch (item.getId()) case 0
showLogin() break
case 1 Intent intent new
Intent(Translate.this, Settings.class)
intent.putExtras(mShownLanguages)
startSubActivity(intent, SETTINGS)
break // switch return
true
Start an Activity
25A real word example X
Call an other Activity
_at_Override public boolean
onOptionsItemSelected(Menu.Item item)
switch (item.getId()) case 0
showLogin() break
case 1 Intent intent new
Intent(Translate.this, Settings.class)
intent.putExtras(mShownLanguages)
startSubActivity(intent, SETTINGS)
break // switch return
true
Start an Activity
Pass data to new Activity
26A real word example XI
Store user data
_at_Override protected void onPause()
super.onPause() SharedPreferences.Editor
ed mPrefs.edit() for(int i 0 i lt
SUPPORTED_LANGUAGES.length i)
ed.putBoolean(SUPPORTED_LANGUAGESi,
mShownLanguages.getBoolean(SUPPORTED_LANGUAGESi
)) ed.commit()
Persistent store
27A real word example XII
Store user data
28Life cycle
- Life cycle not directly controlled by application
- System can kill an application to free up memory
- Controll through onCreate(), onPause(), onStop()
... methods
- Android has different types of processes,
visible processes, service processes, background
processes ...
- Services can be used for long-lived background
processes
29Trends I
- Eyes-free user interfaces
- Other user interfaces like tones, vibrant alarm,
sensors, actuators
- Leverage hearing and touch
- Ubiquitous computing technologies
30Trends II
31Findings
- Android uses proven technology like Java, XML
and Linux
- It offers a rich API for application development
- There is an initial learning effort
- Android doesnt have many of the limitations
other mobile platforms have
- Trend towards eyes-free user interfaces
32Some figures
- Q4 2007 more than 3 billion mobile subscribers
(world population 6.7 billion)?
- 1.14 billion handsets delivered in 2007
(computers 271.2 million)?
- 118 million where smart phones
- Currently more than 30 mobile platforms
- Symbian leads with 65 share, ahead of Microsoft
on 12, RIM on 11, Apple on 7, and Linux at 5
33Thank you for the attention
Questions?
Find out more at http//code.google.com/android