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

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

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

Android App Development. Muhammad Sharjeel COMSATS Institute of Information Technology, Lahore

Introduction To Android

Android. Operating System and Architecture. Android. Screens. Main features

Android App Development

CS260 Intro to Java & Android 04.Android Intro

Mobile Computing. Introduction to Android

Android Ecosystem and. Revised v4presenter. What s New

Introduction to Android Android Smartphone Programming. Outline University of Freiburg. What is Android? Background University of Freiburg.

Android Overview. Francesco Mercaldo, PhD

Introduction to Android

Introduction to Android

BCA 6. Question Bank

Android App Development. Ahmad Tayeb

SD Module- Android Programming

Android for Ubiquitous Computing Researchers. Andrew Rice University of Cambridge 17-Sep-2011

CSCU9YH Development with Android

IJRDTM Kailash ISBN No Vol.17 Issue

Android Development Tutorial. Yi Huang

Mobile OS. Symbian. BlackBerry. ios. Window mobile. Android

PAPER ON ANDROID ESWAR COLLEGE OF ENGINEERING SUBMITTED BY:

Android Overview. Most of the material in this section comes from

Another difference is that the kernel includes only the suspend to memory mechanism, and not the suspend to hard disk, which is used on PCs.

ANDROID SYLLABUS. Advanced Android

UNIT:2 Introduction to Android

Why Android? Why Android? Android Overview. Why Mobile App Development? 20-Nov-18

Android Application Development

Introduction to Android

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Praktikum Mobile und Verteilte Systeme. Android-Basics. Prof. Dr. Claudia Linnhoff-Popien André Ebert, Sebastian Feld

Programming with Android: Android for Tablets. Dipartimento di Scienze dell Informazione Università di Bologna

Android. Lesson 1. Introduction. Android Developer Fundamentals. Android Developer Fundamentals. to Android 1

Android-Basics. Praktikum Mobile und Verteilte Systeme. Prof. Dr. Claudia Linnhoff-Popien André Ebert, Sebastian Feld

Android Fundamentals - Part 1

Android User Interface Android Smartphone Programming. Outline University of Freiburg

MC Android Programming

Android User Interface

Android System Architecture. Android Application Fundamentals. Applications in Android. Apps in the Android OS. Program Model 8/31/2015

Real-Time Embedded Systems

Android Programming (5 Days)

Android Internals and the Dalvik VM!

Programming with Android: Intents. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Android OS. Operating System based on Linux [ ] [Jonas Teuscher, Alex Cuordileone, Cédric Glaus]

EMBEDDED SYSTEMS PROGRAMMING Application Basics

Introduction. Lecture 1. Operating Systems Practical. 5 October 2016

Android App Development

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

COLLEGE OF ENGINEERING, NASHIK-4

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Developer s overview of the Android platform

Introduction to Android development

Android Development Tools = Eclipse + ADT + SDK

Mobile development initiation

Android Online Training

Android. Michael Greifeneder. Image source: Android homepage

What is Android? Mobile Device Application Development COMPSCI 345

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license

Minds-on: Android. Session 1

IGEEKS TECHNOLOGIES. Software Training Division. Academic Live Projects For BE,ME,MCA,BCA and PHD Students

Open Mobile Platforms. EE 392I, Lecture-6 May 4 th, 2010

Android Training Overview (For Demo Classes Call Us )

Android In Industrial Applications. A Field Report

Android-Basics. Praktikum Mobile und Verteilte Systeme

Embedded Systems Programming - PA8001

Lecture 1 Introduction to Android. App Development for Mobile Devices. App Development for Mobile Devices. Announcement.

COPYRIGHTED MATERIAL. 1Getting Started with Android Programming

Copyright 2014, Oracle and/or its affiliates. All rights reserved.

Mobile and Ubiquitous Computing: Android Programming (part 1)

Gauthier Picard. Ecole Nationale Supérieure des Mines

Security Philosophy. Humans have difficulty understanding risk

COSC 3P97 Mobile Computing

Chapter 1 Hello, Android

Syllabus- Java + Android. Java Fundamentals

Android. (XKE Mars 2009) Erwan Alliaume.

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING

DROID. By S.Gokulakrishnan AP/CSE SCSVMV

Lecture 1 - Introduction to Android

Ahmed Ali Big fan of Android

SHWETANK KUMAR GUPTA Only For Education Purpose

Introduction to Android Application Development. Mike Kvintus Principal Engineer JDSU

Mobile Computing LECTURE # 2

Questions and Answers. Q.1) Which of the following is the most ^aeuroeresource hungry ^aeuroepart of dealing with activities on android?

International Journal of Multidisciplinary Consortium Volume 2 Issue

Android Software Development Kit (Part I)

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

Android Programmierung leichtgemacht. Lars Vogel

Required Core Java for Android application development

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

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

ATC Android Application Development

1. What are the key components of Android Architecture? 2. What are the advantages of having an emulator within the Android environment?

Xin Pan. CSCI Fall

Overview of Activities

The World of Android Development

CS378 -Mobile Computing. Anatomy of and Android App and the App Lifecycle

Mobile and Wireless Systems Programming

Answers to Exercises

Transcription:

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

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

Android What? vandroid 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 - Programming with Android System Architecture 3

Android What? ANDROID MICROWAVE SMART FRIDGE SMARTPHONES TABLETS EREADERS ANDROID TV GOOGLE GLASSES? Luca Bedogni - Programming with Android System Architecture 4

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 - Programming with Android System Architecture 5

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 - Programming with Android System Architecture 6

Android When? 2012 2013 2014 Ø Android 4.4 (Kitkat) Released Ø Wireless printing capability Ø Ability for applications to use "immersive mode Ø Performance optimization Ø New experimental runtime virtual machine, ART ANDROID 5.0 Time API Level 19 (Android 4.4): Ø Support to new embedded sensors (e.g. STEP_DETECTOR) Ø Adaptive video playback functionalities Ø Read and write SMS and MMS messages (managing default text messaging client) Luca Bedogni - Programming with Android System Architecture 7

Android market share Luca Bedogni - Programming with Android System Architecture 8

Android heterogeneity http://opensignal.com/reports/fragmentation-2013/ 11,868 different devices in 2013! Luca Bedogni - Programming with Android System Architecture 9

Android heterogeneity http://opensignal.com/reports/2015/08/android-fragmentation/ 24,093 different devices in 2015! Luca Bedogni - Programming with Android System Architecture 10

Android heterogeneity http://opensignal.com/reports/2015/08/android-fragmentation/ 24,093 different devices in 2015! Luca Bedogni - Programming with Android System Architecture 11

Android heterogeneity Luca Bedogni - Programming with Android System Architecture 12

Android heterogeneity 2013 2015 Luca Bedogni - Programming with Android System Architecture 13

Android heterogeneity Luca Bedogni - Programming with Android System Architecture 14

Android heterogeneity Luca Bedogni - Programming with Android System Architecture 15

Android heterogeneity http://developer.android.com/about/dashboards/index.html Luca Bedogni - Programming with Android System Architecture 16

Android heterogeneity Luca Bedogni - Programming with Android System Architecture 17

Android heterogeneity Luca Bedogni - Programming with Android System Architecture 18

Android heterogeneity Luca Bedogni - Programming with Android System Architecture 19

Android When? ANDROID APP CATEGORIES ANDROID APP PRICE http://www.appbrain.com/stats/android-market-app-categories http://www.onlinemarketing-trends.com/2011/07/androidmarketplace-top-5-statistics.html Luca Bedogni - Programming with Android System Architecture 20

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

The Android Architecture Built on top of Linux kernel (v. 2.6-3.4) Advantages: Ø Portability (i.e. easy to compile on different hardware architectures) Ø Security (e.g. secure multi-process environment) Ø Power Management Luca Bedogni - Programming with Android System Architecture 22

The Android Architecture HAL Advantages: Ø Shadows the real device Ø Manages different devices of the same type Luca Bedogni - Programming with Android System Architecture 23

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 - Programming with Android System Architecture 24

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

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

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 ØART optional from 4.4, mandatory from 5.0 Luca Bedogni - Programming with Android System Architecture 27

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 - Programming with Android System Architecture 28

ART Ø ART introduces ahead-of-time compilation Ø At install time, dex2oat convert dex files to executables Ø Improved garbage collection Ø Only one GC pause Ø Parallelized processes Ø More debugging features Ø Improved diagnostic Luca Bedogni - Programming with Android System Architecture 29

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

Android Applications Design APPLICATION COMPONENTS Ø Activities & Fragments Ø Intents Ø Services Ø Content Providers Ø Broadcast Receivers Luca Bedogni - Programming with Android System Architecture 31

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 - Programming with Android System Architecture 32

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 - Programming with Android System Architecture 33

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 - Programming with Android System Architecture 34

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 - Programming with Android System Architecture 35

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 - Programming with Android System Architecture 36

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 - Programming with Android System Architecture 37

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 - Programming with Android System Architecture 38

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 - Programming with Android System Architecture 39

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 - Programming with Android System Architecture 40

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 luca Welcome Luca! Activity1 PASSWORD ********** Login Login Intent Activity2 Luca Bedogni - Programming with Android System Architecture 41

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 - Programming with Android System Architecture 42

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 - Programming with Android System Architecture 43

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 - Programming with Android System Architecture 44

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 - Programming with Android System Architecture 45

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 - Programming with Android System Architecture 46

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 - Programming with Android System Architecture 47

Android Components: Google API Ø or easily interface with other Google services: Luca Bedogni - Programming with Android System Architecture 48

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 - Programming with Android System Architecture 49

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 - Programming with Android System Architecture 50

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. Ø Everything changes starting from 6.0 ANDROIDMANIFEST.XML <uses-permission android:name= android.permission.access_fine_location" /> <uses-permission android:name= android.permission.internet" /> Luca Bedogni - Programming with Android System Architecture 51