Está en la página 1de 23

Google Android

Based on android-sdk_1.6-r1

Mobile Computing

Bruce Scharlau, University of Aberdeen, 2009


Android is part of the ‘build a
better phone’ process
Open Handset Alliance produces
Android

Comprises handset manufacturers,


software firms, mobile operators, and
other manufactures and funding
companies

http://www.openhandsetalliance.com/

Bruce Scharlau, University of Aberdeen, 2009


Android is growing
http://www.admob.com/marketing/pdf/mobile_metrics_jan_09.pdf

http://metrics.admob.com/ - Sept 2009


Small, 1% of online Bigger, 10% of
web requests Bruce Scharlau, University of Aberdeen, 2009
online web requests
Android makes mobile Java easier

Well, sort of…

Bruce Scharlau, University of Aberdeen, 2009


http://code.google.com/android/goodies/index.html
Android applications are written
in Java
package com.google.android.helloactivity;

import android.app.Activity;
import android.os.Bundle;

public class HelloActivity extends Activity {


public HelloActivity() {
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.hello_activity);
}
}

Bruce Scharlau, University of Aberdeen, 2009


Android applications are
compiled to Dalvik bytecode
Write app in Java

Compiled in Java

Transformed to Dalvik bytecode

Loaded into Dalvik VM

Linux OS

Bruce Scharlau, University of Aberdeen, 2009


The Dalvik runtime is optimised
for mobile applications

Run multiple VMs efficiently

Each app has its own VM

Minimal memory footprint


Bruce Scharlau, University of Aberdeen, 2009
Android has many components

Bluetooth and USB drivers now gone from kernel


Bruce Scharlau, University of Aberdeen, 2009
XMPP gone from application framework
Android has a working emulator

Bruce Scharlau, University of Aberdeen, 2009


All applications are written in
Java and available to each other

Android designed to enable reuse of


components in other applications

Each application can publish its


capabilities which other apps can use

Bruce Scharlau, University of Aberdeen, 2009


Android applications have
Views such as common structure
lists, grids, text An Activity Manager that
boxes, buttons, manages the life cycle of
and even an applications and provides
embeddable web a common navigation
browser backstack

Content A Notification Manager


Providers that that enables all apps to
enable display custom alerts in the
applications to status bar
access data from
other applications
A Resource Manager,
(such as
providing access to non-
Contacts), or to
code resources such as
share their own
localized strings,
data
graphics, and layout files
Bruce Scharlau, University of Aberdeen, 2009
Android applications have
common structure
Broadcast
Activity is the presentation
receivers can
layer of your app: there will
trigger intents that
be one per screen, and the
start an application
Views provide the UI to the
activity
Data storage
provide data for
Intents specify what
your apps, and
specific action should be
can be shared
performed
between apps –
database, file,
and shared Services run in the
preferences background and have
(hash map) used no UI for the user –
by group of they will update data,
applications and trigger events

Bruce Scharlau, University of Aberdeen, 2009


There is a common file structure
for applications
code
Autogenerated
files resource list
images

UI layouts

constants

Bruce Scharlau, University of Aberdeen, 2009


Standard components form
building blocks for Android apps
Notifications
Has life-cycle
Activity
screen
Views
App to handle content
Intents
Background app
Service Like music player

manifest

ContentProviders Other applications


Bruce Scharlau, University of Aberdeen, 2009
The AndroidManifest lists
application details
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my_domain.app.helloactivity">
<application android:label="@string/app_name">
<activity android:name=".HelloActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

Bruce Scharlau, University of Aberdeen, 2009


Activity is one thing you can do

Bruce Scharlau, University of Aberdeen, 2009


From fundamentals page in sdk
Intent provides late running
binding to other apps

It can be thought of as the glue between


activities. It is basically a passive data
structure holding an abstract description of
an action to be performed.

Written as action/data pairs such as:


VIEW_ACTION/ACTION content://contacts/1

Bruce Scharlau, University of Aberdeen, 2009


Services declared in the manifest
and provide support
Services run in the background:
Music player providing the music playing in
an audio application

Intensive background apps, might need to


spawn their own thread so as to not block
the application
Bruce Scharlau, University of Aberdeen, 2009
Notifications let you know of
background events
This way you know that an SMS arrived,
or that your phone is ringing, and the
MP3 player should pause

Bruce Scharlau, University of Aberdeen, 2009


ContentProviders share data

You need one if your application shares data


with other applications

This way you can share the contact list with the
IM application

If you don’t need to share data, then you can


use SQLlite database

Bruce Scharlau, University of Aberdeen, 2009


UI layouts are in Java and XML

setContentView(R.layout.hello_activity); //will load the XML UI file


Bruce Scharlau, University of Aberdeen, 2009
Security in Android follows
standard Linux guidelines
Each application runs in its own process
Process permissions are enforced at user
and group IDs assigned to processes
Finer grained permissions are then
granted (revoked) per operations

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.app.myapp" >
<uses-permission id="android.permission.RECEIVE_SMS" />
</manifest>
Bruce Scharlau, University of Aberdeen, 2009
There are lots of sources of
information
• The sdk comes with the API references,
sample applications and
docs/resources/bootcamp.pdf
• There are Google news groups
• There is http://www.anddev.org
• There is Google search

Bruce Scharlau, University of Aberdeen, 2009

También podría gustarte