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? 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 - 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 Ø Google buys Android from the Android Inch Ø Open Handset Alliance ( OHA ) created for open 2006 standards for mobile devices. Partners of OHA: Google, Motorola, Samsung, Vodafone, T-Mobile, etc 2007 Ø Android 1.0 Released 2008 Ø The first Android smartphone: G1 HTC-Dream 2009 Ø Android 1.1 Released Ø Android 1.5 (CupCake) Released Time Luca Bedogni - Programming with Android – System Architecture 5
Android … When? Ø Android 1.6 ( Donut ) Released 2008 Ø Android 2.0 ( Eclair ) Released 2009 Ø Android 2.2 ( Froyo ) Released 2010 Ø Android 2.3 ( Gingerbread ) Released Ø Android 3.0 ( Honeycomb ) Released 2011 (First version for devices with larger screens such as tablets) 2012 Ø 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.) Time Luca Bedogni - Programming with Android – System Architecture 6
Android … When? Ø Android 4.4 ( Kitkat ) Released 2012 Ø Wireless printing capability 2013 Ø Ability for applications to use "immersive mode” Ø Performance optimization 2014 Ø New experimental runtime virtual machine, ART… API Level 19 (Android 4.4): ANDROID 5.0 Ø 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) Time 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/android- marketplace-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 memory- constrained 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 Java Source Java Standard Edition Code Code Java Java Compiler Compiler Java Byte Java Byte Code Code Dex Compiler Stack-based Dalvik Byte byte-code Code Register-based byte-code Java Virtual Dalvik Virtual Machine (JVM) Machine (VM) 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 Ø An Application can be composed of multiples screens (Activities). Button1 Ø The Home Activity is shown when the user Hello World! 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 TextView android.text=@string/hello” android:textcolor=@color/blue android:layout_width=“fill_parent” android:layout_height=“wrap_content” /> < Button 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 - Build the application layout through XML files (like HTML) - Define two different XML layouts for two different devices Device 1 Device 2 - At runtime , Android detects the HIGH screen pixel density LOW screen pixel density current device configuration and loads the appropriate resources Java App Code for the application - No need to recompile ! - Just add a new XML file if you need to support a new device XML Layout File XML Layout File Device 1 Device 2 Luca Bedogni - Programming with Android – System Architecture 35
Recommend
More recommend