Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna



Similar documents
Android Basics. Xin Yang

Android Architecture. Alexandra Harrison & Jake Saxton

Praktikum Entwicklung Mediensysteme (für Master)

An Introduction to Android Application Development. Serdar Akın, Haluk Tüfekçi

Android Programming and Security

ANDROID. Programming basics

Introduction to Android

Android For Java Developers. Marko Gargenta Marakana

Programming with Android

Lecture 1 Introduction to Android

Android Application Development. Daniel Switkin Senior Software Engineer, Google Inc.

Smartphone market share

An Introduction to Android

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

Creating and Using Databases for Android Applications

ANDROID PROGRAMMING - INTRODUCTION. Roberto Beraldi

@ME (About) Marcelo Cyreno. Skype: marcelocyreno Linkedin: marcelocyreno Mail:

Mobile Application Development 2014

INTRODUCTION TO ANDROID CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 11 02/15/2011

Android 5.0: Lollipop OS

CS378 -Mobile Computing. Android Overview and Android Development Environment

Android Development. Marc Mc Loughlin

Introduction to Android: Hello, Android! 26 Mar 2010 CMPT166 Dr. Sean Ho Trinity Western University

Graduate presentation for CSCI By Janakiram Vantipalli ( Janakiram.vantipalli@colorado.edu )

Frameworks & Android. Programmeertechnieken, Tim Cocx

ANDROID BASED MOBILE APPLICATION DEVELOPMENT and its SECURITY

Introduction to Android SDK Jordi Linares

Getting started with Android and App Engine

Hacking your Droid ADITYA GUPTA

Android Geek Night. Application framework

ANDROID PROGRAMMING - INTRODUCTION. Roberto Beraldi

Programming the Android Platform. Logistics

01. Introduction of Android

ITG Software Engineering

Basics. Bruce Crawford Global Solutions Manager

Specialized Android APP Development Program with Java (SAADPJ) Duration 2 months

Introduction to Android

Admin. Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources. Recap: TinyOS. Recap: J2ME Framework

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

4. The Android System

Android (Basic + Advance) Application Development

Overview. The Android operating system is like a cake consisting of various layers.

Workshop on Android and Applications Development

directory to "d:\myproject\android". Hereafter, I shall denote the android installed directory as

Programming with Android: SDK install and initial setup. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Android Application Development

Module Title: Software Development A: Mobile Application Development

Android Java Live and In Action

ANDROID OPERATING SYSTEM

OpenCV on Android Platforms

Android Application Development

Deep Inside Android. OpenExpo Zurich September 25 th, Gilles Printemps - Senior Architect. Copyright 2007 Esmertec AG.

Mobile Phones Operating Systems

Here to take you beyond Mobile Application development using Android Course details

BEGIN ANDROID JOURNEY IN HOURS

MMI 2: Mobile Human- Computer Interaction Android

UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

Introduction to Android. CSG250 Wireless Networks Fall, 2008

ANDROID INTRODUCTION TO ANDROID

Overview of CS 282 & Android

Programming with Android: SDK install and initial setup. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Android Fundamentals 1

Google Android: An Emerging Innovative Software Platform For Mobile Devices

Developer's Cookbook. Building Applications with. The Android. the Android SDK. A Addison-Wesley. James Steele Nelson To

How To Develop An Android App On An Android Device

Jordan Jozwiak November 13, 2011

A Short Introduction to Android

Android Operating System:

An Introduction to Android. Huang Xuguang Database Lab. Inha University

Mobile Application Development Android

Технологии Java. Android: Введение. Кузнецов Андрей Николаевич. Санкт-Петербургский Государственный Политехнический Университет

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Mobile applications security Android OS (case study) Maciej Olewiński. Cryptographic Seminar r.

Introduction to Android

TUTORIALS AND QUIZ ANDROID APPLICATION SANDEEP REDDY PAKKER. B. Tech in Aurora's Engineering College, 2013 A REPORT

What is Android? originally purchased from Android, Inc. in 2005

Android Developer Fundamental 1

OMX, Android, GStreamer How do I decide what to use? 15 July 2011

Introduction to Android Development. Jeff Avery CS349, Mar 2013

Android Operating System

COURSE CONTENT. GETTING STARTED Select Android Version Create RUN Configuration Create Your First Android Activity List of basic sample programs

Praktikum Entwicklung von Mediensystemen (Android)

Android Concepts and Programming TUTORIAL 1

Choosing a Mobile Application Development Approach

Development. SriSeshaa Technologies. Table of Contents

Lecture 17: Mobile Computing Platforms: Android. Mythili Vutukuru CS 653 Spring 2014 March 24, Monday

Chapter 2 Getting Started

Mobile Applications Grzegorz Budzyń Lecture. 2: Android Applications

Reminders. Lab opens from today. Many students want to use the extra I/O pins on

Android 多 核 心 嵌 入 式 多 媒 體 系 統 設 計 與 實 作

An Android-based Instant Message Application

Transcription:

Programming with Android: System Architecture Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna

Outline Android Architecture: An Overview Android Dalvik Java Virtual Machine Android Components: Activities Android Components: Intents Android Components: Services Android Components: Content Providers Android Application Distribution and Markets Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 2

Android What? v Android is a Linux-based platform for mobile devices Operating System Middleware Applications Software Development Kit (SDK) v Which kind of mobile devices (examples) SMARTPHONES TABLETS EREADERS ANDROID TV GOOGLE GLASSES? Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 3

Android When? 2005 2006 2007 2008 2009 Time Ø Google buys Android from the Android Inch Ø Open Handset Alliance (OHA) created for open standards for mobile devices. Partners of OHA: Google, Motorola, Samsung, Vodafone, T-Mobile, etc Ø Android 1.0 Released Ø The first Android smartphone: G1 HTC-Dream Ø Android 1.1 Released Ø Android 1.5 (CupCake) Released Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 4

Android When? 2008 2009 2010 2011 2012 Time Ø Android 1.6 (Donut) Released Ø Android 2.0 (Eclair) Released Ø Android 2.2 (Froyo) Released Ø Android 2.3 (Gingerbread) Released Ø Android 3.0 (Honeycomb) Released (First version for devices with larger screens such as tablets) Ø Android 4.0 (Ice-Cream Sandwich) Released. (It merges the 3.x tab centric design and the v2.x phone based design into a single version.) Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 5

Android When? 2012 2013 KEY LIME PIE Ø Android 4.2 (Jelly Bean) Released Ø Gesture Mode for Accessibility Ø Improved browser performance Ø Easy data-sharing through NFC Ø Improved camera and face recognition functionalities Ø API Level 17 (Android 4.2): Time Ø Daydream: screensaver customization API Ø Support to multi-user environments Ø Nested fragments for UI improvements Ø Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 6

Android When? ANDROID DISTRIBUTIONS ANDROID APPLICATIONS x http://developer.android.com/about/dashboards/index.html http://www.appbrain.com/stats/android-market-app-categories Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 7

Android When? http://en.wikipedia.org/wiki/android_version_history 1.6-2.0 2.2.x 2.3.x ANDROID VERSION HISTORY AND POPULARITY (2009-2013) 4.x Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 8

The Android Architecture } Stack Architecture Open Source Architecture (Apache/MIT License v. 2.0) Business-friendly License Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 9

The Android Architecture Built on top of Linux kernel (v. 2.6-3.0) Advantages: Ø Portability (i.e. easy to compile on different harwdare architectures) Ø Security (e.g. secure multi-process environment) Ø Power Management Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 10

The Android Architecture Native Libraries (C/C++ code) Ø Graphics (Surface Manager) Ø Multimedia (Media Framework) Ø Database DBMS (SQLite) Ø Font Management (FreeType) Ø WebKit Ø C libraries (Bionic) Ø. Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 11

The Android Architecture Application Libraries (Core Components of Android) Ø Activity Manager Ø Packet Manager Ø Telephony Manager Ø Location Manager Ø Contents Provider Ø Notification Manager Ø. Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 12

The Android Architecture Applications (Written in Java code) Ø Android Play Store Ø Entertainment Ø Productivity Ø Personalization Ø Education Ø Geo-communication Ø. Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 13

The Android Architecture Dalvik Virtual Machine (VM) Ø Novel Java Virtual Machine implementation (not using the Oracle JVM) Ø Open License (Oracle JVM is not open!) Ø Optimized for memoryconstrained devices Ø Faster than Oracle JVM Ø. Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 14

Dalvik Java Virtual Machine (JVM) Java Source Code Java Compiler Java Standard Edition Java Source Code Java Compiler Java Byte Code Java Byte Code Java Virtual Machine (JVM) Stack-based byte-code Dalvik Byte Code Dalvik Virtual Machine (VM) Dex Compiler Register-based byte-code Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 15

Android Applications Design APPLICATION DESIGN: Ø GUI Definition Ø Events Management Ø Application Data Management Ø Background Operations Ø User Notifications Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 16

Android Applications Design APPLICATION COMPONENTS Ø Activities Ø Intents Ø Services Ø Content Providers Ø Broadcast Receivers Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 17

Android Components: Activities Ø An Activity corresponds to a single screen of the Application. Android HelloWorld Button1 Hello World! Ø An Application can be composed of multiples screens (Activities). Ø The Home Activity is shown when the user launches an application. Ø Different activities can exhange information one with each other. Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 18

Android Components: Activities Ø Each activity is composed by a list of graphics components. Ø Some of these components (also called Views) can interact with the user by handling events (e.g. Buttons). Ø Two ways to build the graphic interface: PROGRAMMATIC APPROACH Example: Button button=new Button (this); TextView text= new TextView(); text.settext( Hello world ); Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 19

Android Components: Activities Ø Each activity is composed by a list of graphics components. Ø Some of these components (also called Views) can interact with the user by handling events (e.g. Buttons). Ø Two ways to build the graphic interface: DECLARATIVE APPROACH Example: < TextView android.text=@string/hello android:textcolor=@color/blue android:layout_width= fill_parent android:layout_height= wrap_content /> < Button android.id= @+id/button01 android:textcolor= @color/blue android:layout_width= fill_parent android:layout_height= wrap_content /> Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 20

Android Components: Activities EXAMPLE Device 1 HIGH screen pixel density XML Layout File Device 1 Java App Code Device 2 LOW screen pixel density XML Layout File Device 2 - Build the application layout through XML files (like HTML) - Define two different XML layouts for two different devices - At runtime, Android detects the current device configuration and loads the appropriate resources for the application - No need to recompile! - Just add a new XML file if you need to support a new device Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 21

Android Components: Activities Ø Android applications typically use both the approaches! DECLARATIVE APPROACH XML Code Define the Application layouts and resources used by the Application (e.g. labels). PROGRAMMATIC APPROACH Java Code Manages the events, and handles the interaction with the user. Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 22

Android Components: Activities Ø Views can generate events (caused by human interactions) that must be managed by the Android-developer. Button TextEdit ESEMPIO public void onclick(view arg0) { if (arg0 == Button) { // Manage Button events } } Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 23

Android Components: Activities Ø The Activity Manager is responsible for creating, destroying, managing activities. Ø Activities can be on different states: starting, running, stopped, destroyed, paused. Ø Only one activity can be on the running state at a time. Ø Activities are organized on a stack, and have an event-driven life cycle (details later ) Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 24

Android Components: Activities Ø Main difference between Android-programming and Java (Oracle) -programming: Ø Mobile devices have constrained resource capabilities! Ø Activity lifetime depends on users choice (i.e. change of visibility) as well as on system contraints (i.e. memory shortage). Ø Developer must implement lifecycle methods to account for state changes of each Activity Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 25

Android Components: Activities public class MyApp extends Activity { Called when the Activity is created the first time. } public void oncreate() {... } public void onpause() {... } public void onstop() {... } public void ondestroy(){... }. Called when the Activity is partially visible. Called when the Activity is no longer visible. Called when the Activity is dismissed. Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 26

Android Components: Intents Ø Intents: asynchronous messages to activate core Android components (e.g. Activities). Ø Explicit Intent à The component (e.g. Activity1) specifies the destination of the intent (e.g. Activity 2). LOGIN marco Welcome Marco! Activity1 PASSWORD ********** Login Login Intent Activity2 Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 27

Android Components: Intents Ø Intents: asynchronous messages to activate core Android components (e.g. Activities). Ø Implicit Intent à The component (e.g. Activity1) specifies the type of the intent (e.g. View a video ). Activity1 View Multiple choices might be available to the user! Implicit Intent Activity2 Activity2 } Intent- Filters Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 28

Android Components: Services Ø Services: like Activities, but run in background and do not provide an user interface. Ø Used for non-interactive tasks (e.g. networking). Ø Service life-time composed of 3 states: Starting Destroyed oncreate() onstart() ondestroy() Running (on background) Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 29

Android Components: Content Providers Ø Each Android application has its own private set of data (managed through files or through SQLite database). Ø Content Providers: Standard interface to access and share data among different applications. insert() APP update() delete() Content Provider DB query() e.g. Photo Gallery Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 30

Android Components: Broadcast Receivers Ø Publish/Subscribe paradigm Ø Broadcast Receivers: An application can be signaled of external events. Ø Notification types: Call incoming, SMS delivery, Wifi network detected, etc Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 31

Android Components: Broadcast Receivers BROADCAST RECEIVER example class WifiReceiver extends BroadcastReceiver { } public void onreceive(context c, Intent intent) { String s = new StringBuilder(); } wifilist = mainwifi.getscanresults(); for(int i = 0; i < wifilist.size(); i++){ } s.append(new Integer(i+1).toString() + "."); s.append((wifilist.get(i)).tostring()); s.append("\\n"); maintext.settext(sb); Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 32

Android Components: Broadcast Receivers BROADCAST RECEIVER example public class WifiTester extends Activity { WifiManager mainwifi; WifiReceiver receiverwifi; List<ScanResult> wifilist; public void oncreate(bundle savedinstancestate) { mainwifi = (WifiManager) getsystemservice (Context.WIFI_SERVICE); receiverwifi = new WifiReceiver(); registerreceiver(receiverwifi, new IntentFilter (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); } mainwifi.startscan(); Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 33

Android Components: System API Ø Using the components described so far, Android applications can then leverage the system API SOME EXAMPLEs Ø Telephony Manager data access (call, SMS, etc) Ø Sensor management (GPS, accelerometer, etc) Ø Network connectivity (Wifi, bluetooth, NFC, etc) Ø Web surfing (HTTP client, WebView, etc) Ø Storage management (files, SQLite db, etc) Ø. Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 34

Android Components: Google API Ø or easily interface with other Google services: Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 35

Android Application Distribution APK FILE XML Files C Ø Each Android application is contained on a single APK file. Ø Java Byte-code (compiled for Dalvik JVM) Ø Resources (e.g. images. videos, XML layout files) Ø Libraries (optimal native C/C++ code) Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 36

Android Application Distribution Ø Each application must be signed through a key before being distributed. Ø Applications can be distributed via Web or via Stores. Ø Android Play Store: application store run by Google but several other application stores are available (they are just normal applications). Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 37

Android Application Security Ø Android applications run with a distinct system identity (Linux user ID and group ID), in an isolated way. Ø Applications must explicitly share resources and data. They do this by declaring the permissions they need for additional capabilities. Ø Applications statically declare the permissions they require. Ø User must give his/her consensus during the installation. ANDROIDMANIFEST.XML <uses- permission android:name= android.permission.iaccess_fine_location" /> <uses- permission android:name= android.permission.internet" /> Luca Bedogni, Marco Di Felice - Programming with Android System Architecture 38