android

26
Mandus Elfving, IBS JavaSolutions, 2009 Android

Upload: peterbuck

Post on 14-Jan-2015

2.447 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Android

Mandus Elfving, IBS JavaSolutions, 2009

Android

Page 2: Android

What is Android?

• Operating system and platform for mobile devices

• Developed by Google and later by the Open Source Handset Alliance

• Mostly open sourced under the Apache and other open source licenses

Page 3: Android

Android features• Integrated browser based on the open source WebKit engine

• Optimized graphics powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional)

• SQLite for structured data storage

• Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF)

• GSM Telephony (hardware dependent)

• Bluetooth, EDGE, 3G, and WiFi (hardware dependent)

• Camera, GPS, compass, and accelerometer (hardware dependent)

Page 4: Android

Architecture

Page 5: Android

Why is Android interesting to us?

Application development is done in Java!

Page 6: Android

Dalvik Virtual Machine

• Optimized for mobile devices

• Relies on the underlying OS for process separation, memory management and threading

• Designed to run multiple VM instances efficiently

• Executes its own type of byte code in files created from Java class files

Page 7: Android

Android vs. Java

• Based on Apache Harmony

• Supports most of the J2SE 5.0 library

• Applets, printing and other irrelevant stuff left out

• Includes third party libraries, e.g. bluetooth and JSON libraries

Page 8: Android

Applications

• Comes in .apk files which contain the application code and resources

• Run in their own Linux process

• Each process has its own VM

• Applications are assigned a unique user id that make sure that application data is private

Page 9: Android

Application building blocks

• Applications consist of components that are the entry points of an application

• Applications can use components from other applications

• Four types of components:

• Activities• Services• Broadcast receivers• Content providers

Page 10: Android

Application Building Blocks con't

Components declared in AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest . . . > <application . . . > <activity android:name="com.example.project.HelloWorldActivity" android:icon="@drawable/helloWorld.png" android:label="@string/helloWorldLabel" . . . > </activity> . . . </application></manifest>

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="se.jsolutions.android"> <application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name="HelloWorldActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>

</application></manifest>

Page 11: Android

Activities

• Interface for one of the activities that a user undertake in an application

• Applications are (usually) built from multiple activities

• The UI for an activity is built with Views

Page 12: Android

Services

• Used for long running background processes, e.g. media player

• Can run on its own in the background and/or be operated by an interface

• Run in the main thread of the application process

• Spawn thread to not block main thread

Page 13: Android

Broadcast receivers

• Components that react to system or application broadcasts

• System broadcasts for example when the battery level is low or the timezone changed

• Applications can initiate broadcasts that other applications can react to

Page 14: Android

Content providers

• Application data is by default private to the application

• Content providers make an applications private data available to other applications through a standardized API

• Accessed through a ContentResolver with an URI of the content provider to use, e.g. content://com.example.addressbook/contacts

• Android ships with standard content providers for common data types (audio, video, contacts, etc.)

Page 15: Android

Application navigation

• Components are activated by intents

• Intents are asynchronous messages

• Intents contain information relevant to the receiving component, e.g. action to take and data to act on

• Also contain information that the system use for finding the component that should handle it

Page 16: Android

Application navigation con't

• Components can be targeted explicitly or implicitly

• Intent filters define that a component can handle a specific implicit intents

• The system locates the best component to respond to an implicit intent

• Intent filters are defined in the manifest file

Page 17: Android

Application life cycle

• Tasks are groups of related activities arranged in a stack

• Tasks can be sent to the background or moved to the foreground

• Only one task and activity running at the same time

Page 18: Android

Application life cycle con't

• When system runs low on memory applications can be killed

• All applications are placed in an “importance hierarchy” to determine which application to kill next

• Importance is based on the components running in an application and their state

Page 19: Android

Application framework

• Consists of a set of services and systems to help in application development

• For example used to support localized applications and to build the graphical UI

• Used by core applications such as the SMS and Contacts applications

Page 20: Android

Views

Page 21: Android

Resource manager

• Provides access to non-code related resources such as localized strings or graphics

• Resources are compiled in to the application binary (resources reside in the res/ folder)

• Used by referencing symbols that are generated when the application is compiled (available in the R class), e.g. R.string.app_name or @string/app_name

Page 22: Android

Notification manager

• Allows the application to notify the user when something has happened in the background

• Different kinds:

• Icon in the status bar• LEDs on the device• Flashing backlight, playing a sound or vibrating

Page 23: Android

Security

• Applications are signed with a certificate

• Applications run in their own process with a unique user id

• Permissions restrict access to the data on the device

• Permissions granted by user on installation of application

• Permissions that application need and declaration of custom permissions is done in the application manifest file

Page 24: Android

Development environment

• Android SDK

• Command-line tools

• Eclipse with an Android plugin

• Execution/debugging in an emulator running the full OS and software stack

Page 25: Android

Phones

• First phone released October 2008 by T-mobile in the US and UK

• New phones during 2009 from the large phone companies

Page 26: Android

More information at:http://developer.android.com/