23
Bruce Scharlau, University of Aberdeen, 2010 Google Android Mobile Computing Based on android-sdk_2.2

android

Embed Size (px)

Citation preview

Page 1: android

Bruce Scharlau, University of Aberdeen, 2010

Google Android

Mobile Computing

Based on android-sdk_2.2

Page 2: android

Bruce Scharlau, University of Aberdeen, 2010

Android is part of the ‘build a better phone’ process

Open Handset Alliance produces Android

Open Handset Alliance produces Android

Comprises handset manufacturers, software firms, mobile operators, and other manufactures and funding companies

Comprises handset manufacturers, software firms, mobile operators, and other manufactures and funding companies

http://www.openhandsetalliance.com/

Page 3: android

Bruce Scharlau, University of Aberdeen, 2010

Android is growing

http://metrics.admob.com/wp-content/uploads/2010/06/May-2010-AdMob-Mobile-Metrics-Highlights.pdf

Does not include iTouch or iPad, as not smartphones

Uneven distribution of OS by regions

Page 4: android

Bruce Scharlau, University of Aberdeen, 2010

Android makes mobile Java easier

http://code.google.com/android/goodies/index.html

Well, sort of…

Page 5: android

Bruce Scharlau, University of Aberdeen, 2010

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); }}

Page 6: android

Bruce Scharlau, University of Aberdeen, 2010

Android applications are compiled to Dalvik bytecode

Write app in JavaWrite app in Java

Compiled in JavaCompiled in Java

Transformed to Dalvik bytecodeTransformed to Dalvik bytecode

Linux OS Linux OS

Loaded into Dalvik VMLoaded into Dalvik VM

Page 7: android

Bruce Scharlau, University of Aberdeen, 2010

The Dalvik runtime is optimised for mobile applications

Run multiple VMs efficientlyRun multiple VMs efficiently

Each app has its own VMEach app has its own VM

Minimal memory footprintMinimal memory footprint

Page 8: android

Bruce Scharlau, University of Aberdeen, 2010

Android has many components

Page 9: android

Can assume that most have android 2.1 or 2.2

Bruce Scharlau, University of Aberdeen, 2010http://developer.android.com/resources/dashboard/platform-versions.html

Page 10: android

Bruce Scharlau, University of Aberdeen, 2010

Android has a working emulator

Page 11: android

Bruce Scharlau, University of Aberdeen, 2010

All applications are written in Java and available to each other

Android designed to enable reuse of components in other applications

Android designed to enable reuse of components in other applications

Each application can publish its capabilities which other apps can use

Each application can publish its capabilities which other apps can use

Page 12: android

Bruce Scharlau, University of Aberdeen, 2010

Android applications have common structureViews such as

lists, grids, text boxes, buttons, and even an embeddable web browser

Views such as lists, grids, text boxes, buttons, and even an embeddable web browser

Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data

Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data

A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files

A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files

A Notification Manager that enables all apps to display custom alerts in the status bar

A Notification Manager that enables all apps to display custom alerts in the status bar

An Activity Manager that manages the life cycle of applications and provides a common navigation backstack

An Activity Manager that manages the life cycle of applications and provides a common navigation backstack

Page 13: android

Bruce Scharlau, University of Aberdeen, 2010

Android applications have common structure

Broadcast receivers can trigger intents that start an application

Broadcast receivers can trigger intents that start an application

Data storage provide data for your apps, and can be shared between apps – database, file, and shared preferences (hash map) used by group of applications

Data storage provide data for your apps, and can be shared between apps – database, file, and shared preferences (hash map) used by group of applications

Services run in the background and have no UI for the user – they will update data, and trigger events

Services run in the background and have no UI for the user – they will update data, and trigger events

Intents specify what specific action should be performed

Intents specify what specific action should be performed

Activity is the presentation layer of your app: there will be one per screen, and the Views provide the UI to the activity

Activity is the presentation layer of your app: there will be one per screen, and the Views provide the UI to the activity

Page 14: android

Bruce Scharlau, University of Aberdeen, 2010

There is a common file structure for applications

code

images

files

UI layouts

constants

Autogenerated resource list

Page 15: android

Bruce Scharlau, University of Aberdeen, 2010

Standard components form building blocks for Android apps

Other applications

Has life-cycle

screen

App to handle content

Background appLike music player

Views

manifest

Activity

Intents

Service

Notifications

ContentProviders

Page 16: android

Bruce Scharlau, University of Aberdeen, 2010

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>

Page 17: android

Bruce Scharlau, University of Aberdeen, 2010

Activity is one thing you can do

From fundamentals page in sdk

Page 18: android

Bruce Scharlau, University of Aberdeen, 2010

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

Written as action/data pairs such as: VIEW_ACTION/ACTION content://contacts/1

Page 19: android

Bruce Scharlau, University of Aberdeen, 2010

Services declared in the manifest and provide support

Services run in the background:Music player providing the music playing in

an audio application

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

Intensive background apps, might need to spawn their own thread so as to not block the application

Page 20: android

Bruce Scharlau, University of Aberdeen, 2010

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

This way you know that an SMS arrived, or that your phone is ringing, and the MP3 player should pause

Page 21: android

Bruce Scharlau, University of Aberdeen, 2010

ContentProviders share data

You need one if your application shares data with other applications

You need one if your application shares data with other applications

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

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

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

Page 22: android

Bruce Scharlau, University of Aberdeen, 2010

UI layouts are in Java and XML

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

Page 23: android

Bruce Scharlau, University of Aberdeen, 2010

Security in Android follows standard Linux guidelines

Each application runs in its own processEach application runs in its own process

Process permissions are enforced at user and group IDs assigned to processes

Process permissions are enforced at user and group IDs assigned to processes

Finer grained permissions are then granted (revoked) per operations

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>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.android.app.myapp" ><uses-permission id="android.permission.RECEIVE_SMS" /></manifest>