Upload
peterbuck
View
1.384
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
COMP 5047 Pervasive Computing: Week 4: Smartphones & the Android OS
Dr.-Ing. Rainer Wasinger
School of Information Technologies
Background:
2
• A good book: Multimodal Interaction with Mobile
Devices
Background:
• Mobile Device Projects at the DFKI
3
Background:
• Smart Services CRC
4
Background:
• Multi-Channel Content Repurposing & Mobile
Personalisation
5
Part 1: Phone Statistics
6
Statistics: Mobile phone growth
• 4.1 billion mobile subscriptions in the world, representing a
global penetration rate of 61.1%
• 1.27 billion fixed line subscribers, representing a global
penetration rate of 18.9%.
7
Source: International Telecommunication Union’s ICT Development Index
(IDI) for 2008.
Statistics: Top 5 handsets in the US, Q1 2009
• 1Q2009 US consumer sales of smartphone
handsets:
• 1. RIM BlackBerry Curve (all 83XX models).
• 2. Apple iPhone 3G (all models).
• 3. RIM BlackBerry Storm
• 4. RIM BlackBerry Pearl (all models, except flip).
• 5. T-Mobile G1.
Source: “RIM Unseats Apple in The NPD Group‟s Latest
Smartphone Ranking”, Port Washington, New York, May 4,
2009.
8
Statistics: Mobile terminal, smartphone, and operating
system market share
9
Worldwide mobile terminal
sales to end users in 1Q2009
(source: Gartner).
Worldwide smartphone
sales to end users in 1Q2009
(source: Gartner).
Smartphone OS market
share in 4Q2008
(source: Gartner).
Statistics: Specific to Android
Android: Seven Months, By The Numbers
• 10 carriers in 12 countries
• 4,900+ applications in the Android Market
• 40+ app downloads per user
• #2 in U.S. mobile web browsing
• 3 platform releases, and counting…Source: Google I/O Conference 2009, 28.May.2009.
10
Statistics Specific to the G1 Handset
• Approximately 1.5 million G1s were ordered since October 2008
• Customers purchasing a G1 from T-Mobile were trading up from a
basic handset 50% of the time.
• 50% of the G1 customers access Wi-Fi daily.
• 80% of G1 owners browse the web at least once a day
• 80% of the people owning a G1 download an Android application at
least once a week
• The vast majority of T-Mobile G1 owners use Facebook and YouTube
at least once a week
• The average G1 T-Mobile customers consumers 50 times the data vs.
the average voice-centric phone user.
Source: Robert Dotson, CEO of T-Mobile USA, 04.April 2009
11
Statistics: Android Forecast for 2009
• “We forecast global Android smartphone
shipments to grow an impressive 900% annually
during 2009…Android is expanding from a low
base and it is consequently outgrowing the iPhone
OS from Apple, which we estimate will grow at a
relatively lower 79% annually in 2009.”
Source: Tom Kang, Senior Analyst at Strategy
Analytics, 12.May.2009.
12
Android Smartphone Device Characteristics
13
HTC Dream HTC Magic
Android Smartphone Device CharacteristicsMobile Device HTC Dream HTC Magic
Release date Oct 2008 May 2009
OS Android Android
Display 3.2”, 320x480 (HVGA), capacitive “”
Dimensions 117.7mm x 55.7mm x 17.1mm 113mm x 55m x 13.65mm
Weight 158g 118.5g
Processor Qualcomm MSM7201A 528MHz “”
Memory 256MB ROM, 192MB RAM 512MB ROM, 192MB RAM
Battery 1150mAh 1340mAh
Network HSDPA/WCDMA (1700, 2100MHz),
Quad-band GSM/GPRS/EDGE (850,
900, 1800, 1900MHz)
HSDPA/WCDMA (900, 2100MHz),
Quad-band GSM/GPRS/EDGE
(850, 900, 1800, 1900MHz)
Camera 3.2MP with auto focus “”
WiFi WiFi 802.11b/g “”
Bluetooth Bluetooth 2.0 with EDR “”
Sensors GPS, digital compass, accelerometer “”
14
Other Smartphones on the Market
15
Blackberry Storm
HTC Touch Pro 2
HTC Hero
iPhone 3GS
Palm Pre
Competing mobile Operating Systems
• Competing mobile Operating Systems include:
• Windows Mobile OS:
• Closed source.
• Apple iPhone OS:
• Closed source.
• BlackBerry OS:
• Closed source.
• Palm webOS (released June.2009).
• Closed-source, with open-source components.
• Nokia Symbian OS.
• Currently closed-source, though the recently established Symbian
Foundation are working on publishing the Symbian platform (slated for
mid 2010) royalty-free under the open source Eclipse Public License
(EPL).
16
Part 2: Smartphone Evolution
17
History: 1st Mobile Phone
• 1st mobile phone: The Motorola DynaTac,
released in 1978, providing telephony services for
people on the go.
18
History: 1st PDA
• 1st PDA: The Apple/Sharp Newton MessagePad, released
in 1993, providing personal information management
services, like a personal organiser and an address book.
19
• By 2002, and after 10 years
growth, PDA shipments
began experiencing a decline
(also due to a world-wide
economic down-turn, and the
smart phone emerged.
History: The Universal Mobile Terminal
• The UMT refers to the fictional digital convergence device
of the future, and is based on the convergence of the 3C‟s,
i.e. computing, communication, and consumer electronics.
– Convergence of computing and communication has
already taken place, resulting in the smart phone.
– The 3rd C, consumer electronics, refers to electronic
consumer devices. It is still anyone‟s guess as to how
consumer electronics will influence the design of the
future UMT.
• E.g.: Mobile entertainment devices such as music players (e.g.
Apple iPod, Sony Walkman), video players, handheld
televisions, and gaming devices (e.g. the Nokia N-Gage).
20
History: Limitations of convergence
• In many cases, simple and easy-to-use single-function devices are
preferred by users over multifunctional combos. Design tradeoffs
arising as a result of device convergence are inevitable.
• Some mobile device types that are resisting convergence (and even
newly emerging):
– Mobile Internet Devices (MIDs) like the Apple iTouch
– E-books like the Amazon Kindle
– In-car navigation consoles like the Tom Tom Go
– Gaming consoles like the Nintendo DS
– So-called „social phones‟ like the INQ1/Hutchison 3 Facebook phone.
• These devices are all hoping to have found niches in the market,
based on device convergence design tradeoffs.
21
Definition of a Smartphone
• Smartphone: A mobile device that exhibits converged PDA and phone
functionality.
– Typically support, in addition to voice communication, PIM (e.g.
applications like a calendar, address book, clock, and notepad).
– Modern smartphones also typically provide the ability to:
• send/receive emails and instant messages,
• access the Internet and related web-based services, including but not
limited to social networking sites like Facebook, MySpace, and Twitter.
• install rich 3rd party applications that have access to much of a
system‟s underlying resources.
• Note however that there is no industry agreement as to what precisely
constitutes a „smart‟ phone.
22
Part 3: Android OS
23
Android OS
24
• Android OS:
– An open source mobile platform based on the Linux operating
system.
– Applications are developed using the Java programming language.
– Applications run on Dalvik, a custom virtual machine designed for
embedded use, which runs on top of a Linux kernel.
– Although Android reuses the Java language syntax, it does not
provide the full-class libraries and APIs bundled with Java SE or
Java ME, using the Harmony Java implementation instead (due to
Apache‟s license allowing for closed source derived works).
– The latest Android OS release is 1.5, released on 30.April.2009.
Android OS
• Android, License:
– Most of the Android code has been released under the Apache License.
• Although Android is an open-source product, some development has been
continuing in a private development branch.
– Apache License allows vendors to add proprietary extensions without
submitting those back to the open source community.
• Android, Origins:
– Developed originally by Google, and later/now by the Open
Handset Alliance.
– Announced on 05.November.2007, together with the founding of
the Open Handset Alliance (OHA).
• The OHA:
– A consortium of 50 firms (hardware, software, and telecoms)
devoted to advancing open standards for mobile devices
• Companies include: Google, HTC, Intel, Motorola, Qualcomm, Texas
Instruments, Samsung, LG, T-Mobile.
25
The Android Stack
• The Android platform is a software stack for mobile devices
including:
– An operating
system
– Middleware
– Key applications
26
Android OS Features
27
Android Development
• Required software for developing for the Android
platform (for Windows XP/Vista, Mac OS X 10.4.8
and later, and Linux):
– Android v1.5 SDK: android-sdk-windows-1.5_r2.zip [172MB]
• http://developer.android.com/
– Eclipse v3.4.2 (Ganymede): eclipse-jee-ganymede-SR2-
win32.zip [167MB]
• http://www.eclipse.org/downloads/
– Android Development Tools (ADT) v0.9 plug-in for Eclipse
• http://developer.android.com/sdk/1.5_r2/installing.html
28
Android Developer Resources
30
• Dev Guide:
Android Developer Resources
• Reference:
31
Some quick questions
• Who hasn‟t used the Eclipse IDE before?
• Who isn‟t familiar with the Java programming
language?
• Who isn‟t familiar with XML?
32
Part 4: Anatomy of an Android Application
• Android applications don‟t have a single entry point for
everything in the application (i.e. not main() function).
Instead, they have essential components that the system
can instantiate and run as needed.
– This is partly to make the applications more crash-resistant.
• There are 4 types of components:
– Activities
– Services
– Broadcast receivers
– Content providers.
• We will focus on the Activity component.
33
Android Components
• Services:
• Services run in the background, often without a visual user
interface.
• E.g. a service might play background music, or might fetch data
over the network.
• Broadcast receivers:
• These are components that do nothing but receive and react to
broadcast announcements.
• E.g. an announcement might be that the time zone has changed,
that the battery is low, or that a picture has been taken.
• Content providers:
• Make a specific set of the application‟s data available to other
applications. Such data can for example be stored in the file
system, in an SQLite database.
34
Android Components (cont.)
• Activities:
– Activities represent the building block of the user
interface.
– An activity presents a visual user interface for one
focused endeavour that the user can undertake.
– E.g. an activity might present a list of contacts to send
messages to, while other activities might deal with the
writing of messages, the viewing of old messages, and
the changing of settings.
– Each activity is independent of the others, and each one
is implemented as a subclass of the Activity base class.
35
Tasks and the Activity Stack
• A „task‟ is what the user experiences as an „application‟. It is a
group of related activities, arranged in a stack.
• The root activity in the stack is the one that began the task, e.g.
the activity the user selected in the application launcher.
• One activity can start another activity. When this happens, the
new activity is pushed onto the stack and it becomes the running
activity.
• When the user presses the back key, the current activity is
popped from the stack, and the previous one resumes as the
running activity.
• Starting a task: An activity is set up as the entry point for a task
by giving it an intent filter with “android.intent.action.MAIN” as
the specified action and “android.intent.category.LAUNCHER”
as the specified category.
36
The Lifecycle of an Activity
• Four essential states:
– Active: i.e. the Activity is running and
is in the foreground of the screen.
– Paused: i.e. the Activity is running,
and is visible, but a notification (or
other) is overlaying part of the screen.
The user may not be able to interact
with the Activity during this time.
– Stopped: The Activity is running, but it
is hidden by other activities that have
been launched.
– Dead: When for e.g. an Activity is
terminated, perhaps due to lack of
available memory.
37
The Lifecycle of an Activity (cont.)
• onCreate() and onDestroy():
– The entire lifetime of an Activity happens between the
first call to onCreate() through to a single final call to
onDestroy().
– An Activity does all of its initial setup in onCreate() and
releases all remaining resources in onDestroy().
• onStart(), onRestart(), and onStop():
• The visible lifetime of an Activity happens between a call to
onStart() until a corresponding call to onStop().
• onStart() is called when an activity is first launched.
• onRestart() is called when an activity is brought back to the
foreground after having been hidden.
• onStop is called when the activity is about to be stopped.
38
The AndroidManifest.xml File
• Before Android can start an application, it must learn that
the component exists. Applications declare their
components in a manifest file that is bundled into the
Android package, i.e. the .apk file that holds the
application‟s code, files, and resources.
• The manifest is a structured XML file and is always named
AndroidManifest.xml for all applications.
• In addition to declaring the application‟s components, it
also identifys any permissions the application expects to be
granted.
39
Intents
• While one Activity will be special in that it is used
to start an application, the other activities also
need to be reached. This is done through the use
of asynchronous messages called Intents.
• An Intent is an object that holds the content of a
message. Intents can be very specific (e.g.
requesting a specific Activity to be launched) or
can be more generic (e.g. when multiple criteria is
needed for selecting an Activity to launch).\
• Activities are launched by passing an Intent object
to the Context.startActivity() method.
40
Intent Filters
• An Intent object can explicitly name a target component. If
it does, Android finds that component and activates it. If a
target is not explicitly named, Android must locate the best
component to respond to the intent.
• A component can have any number of intent filters, each
one declaring a different set of capabilities.
• If a component doesn‟t have any filters, it can be activated
only by intents that explicitly name the component as the
target.
41
Designing the User Interface
• User interfaces are built using View and ViewGroup objects.
• The View class serves as the base for subclasses called “widgets”,
which offer fully implemented UI objects, like text fields and buttons.
• The ViewGroup class serves as the base for subclasses called
“layouts”, which offer different kinds of layout architecture, like linear,
tabular, and relative.
• To attach a view hierarchy tree to the
screen for rendering, an Activity must
call the setContentView() method
and pass a reference to the root node
object.
42
View Hierarchy
Designing the User Interface (cont.)
• The most common way to define a layout and express the
view hierarchy is with an XML layout file.
• Each element in XML is either a View or ViewGroup object.
• View objects are the leaves in the tree.
• ViewGroup objects are the branches in the tree.
• Combining different Views in a nested XML structure is the
basis for GUI creation.
43
Part 5: The Code
44
Notepadv3 in the Eclipse IDE
45
Notepadv3 Example – The Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.demo.notepad3">
<application android:icon="@drawable/icon">
<activity android:name=".Notepadv3"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NoteEdit"/>
</application>
</manifest>
46
Notepadv3 Example – An Activity Class
public class Notepadv3 extends ListActivity {
...
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.notes_list);
mDbHelper = new NotesDbAdapter(this);
mDbHelper.open();
fillData();
registerForContextMenu(getListView());
} //onCreate
...
47
Notepadv3 Example – An Intent
@Override
protected void onListItemClick(ListView l, View v, int position,
long id) {
super.onListItemClick(l, v, position, id);
Intent i = new Intent(this, NoteEdit.class);
i.putExtra(NotesDbAdapter.KEY_ROWID, id);
startActivityForResult(i, ACTIVITY_EDIT);
}
48
Notepadv3 Example – notes_list.xml GUI
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Notes!"/>
</LinearLayout>
49
Part 6: Eclipse – Using the IDE
50
Using the Eclipse IDE
• Editing code
51
Using the Eclipse IDE
52
• Designing a GUI
Using the Eclipse IDE
53
• Using the Debugger
Using the Eclipse IDE
54
• LogCat
COMP5047 Property App Week 5 Lab Task
55
• Screen shots