CHAPTER 1:Android Platform Compiled Android Applications Although ART is now the official runtime for the Android platform starting from Android 5.0,the majority of the Android devices that are running an older version of the Android platform rely on the Dalvik VM. In order to produce application packages and binaries that are compatible with both ART and the Dalvik VM.Android application packages are still pre ecifications.As it was optimized for mobile t type of byted as Da only a speci vik Executable(DEX).The Androi known d SDK comes with to s th translate standard Java bytecode into DEX bytecode during the packaging of the Android application.DEX bytecode provides lots of advantages compared to standard Java bytecode.ART does an automatic conversion from Dalvik's DEX format into ART's OAT format on the fly as soon as an application is installed on the device. Application Sandbox The Android platform is built with security in mind as an important requ em nt.It runs e ery applic ation in sandbo x by isolating application data and code execution from other applications Each application runs on its own dedicated ART VM instance. Application data is protected through the use of file svstem permissions.Each application gets assianed an account at installation.and the operating system restricts access to the application data for that account Applications can only communicate with the system and with other applications through the communication interfaces that the Android platform provides.These interfaces are also protected through Android permissions. Zygote Zygote,also known as the "app process,"is the parent of all Android application processes.It is o system boots.Zygote has tw of those core processes started when the o important roles Once the sys n boots,Zygote starts a new ART VM instance and initializes the core Android services: Power,Telephony,Content,and Package
8 CHAPTER 1: Android Platform Compiled Android Applications Although ART is now the official runtime for the Android platform starting from Android 5.0, the majority of the Android devices that are running an older version of the Android platform rely on the Dalvik VM. In order to produce application packages and binaries that are compatible with both ART and the Dalvik VM, Android application packages are still prepared based on Dalvik specifications. As it was optimized for mobile, the Dalvik VM understands only a special type of bytecode which is known as Dalvik Executable (DEX). The Android SDK comes with tools that can translate standard Java bytecode into DEX bytecode during the packaging of the Android application. DEX bytecode provides lots of advantages compared to standard Java bytecode. ART does an automatic conversion from Dalvik’s DEX format into ART’s OAT format on the fly as soon as an application is installed on the device. Application Sandbox The Android platform is built with security in mind as an important requirement. It runs every application in a sandbox by isolating application data and code execution from other applications. Each application runs on its own dedicated ART VM instance. Application data is protected through the use of file system permissions. Each application gets assigned an account at installation, and the operating system restricts access to the application data for that account. Applications can only communicate with the system and with other applications through the communication interfaces that the Android platform provides. These interfaces are also protected through Android permissions. Zygote Zygote, also known as the “app process,” is the parent of all Android application processes. It is one of those core processes started when the system boots. Zygote has two important roles. Once the system boots, Zygote starts a new ART VM instance and initializes the core Android services: Power, Telephony, Content, and Package
CHAPTER 1:Android Platform 9 As noted,on the Android platform,every application runs within a dedicated ART VM instance.It is a very costly operation to start a new ART VM instance and load the Android framework components into memory for every Android application.Zygote solves this problem through the use of forking.When a user requests a new application,Zygote simply forks itself Upon forking,the existing Zygote e process gets cloned as a new process.Both the Zygote proces s and the new process share the pre-loaded Android framework resources.This allows applications to start very quickly, and also with a much smaller footprint. Note In computing,forking is the operation to clone an existing process The new process has an exact copy of the forked process,although both processes execute independently.Forking allows both processes to share the same memory segment until one of them tries to modify it. Application Framework The Application framework runson the top of the ART VM and provides an interface to Android applications to interact with the Android platform and the device.It provides services such as Package Manager,Telephony Manager,Location Manager,and Notifications Manager. Applications The application space contains all user-facing Android applications that are running on top of the ART VM.Those applications include both third-partyappli are downl ded fror ndroid markets and system applications such as Launcher,Contacts,Phone,and Browser.This book will show you how to use the Android framework APls to develop Android applications that will execute within the application space
CHAPTER 1: Android Platform 9 As noted, on the Android platform, every application runs within a dedicated ART VM instance. It is a very costly operation to start a new ART VM instance and load the Android framework components into memory for every Android application. Zygote solves this problem through the use of forking. When a user requests a new application, Zygote simply forks itself. Upon forking, the existing Zygote process gets cloned as a new process. Both the Zygote process and the new process share the pre-loaded Android framework resources. This allows applications to start very quickly, and also with a much smaller footprint. Note In computing, forking is the operation to clone an existing process. The new process has an exact copy of the forked process, although both processes execute independently. Forking allows both processes to share the same memory segment until one of them tries to modify it. Application Framework The Application framework runs on the top of the ART VM and provides an interface to Android applications to interact with the Android platform and the device. It provides services such as Package Manager, Telephony Manager, Location Manager, and Notifications Manager. Applications The application space contains all user-facing Android applications that are running on top of the ART VM. Those applications include both third-party applications that are downloaded from Android markets and system applications such as Launcher, Contacts, Phone, and Browser. This book will show you how to use the Android framework APIs to develop Android applications that will execute within the application space
CHAPTER 1:Android Platform Android Versions When speaking of Android,you will often hear the same Android version being referred ways. This application requires Jelly Bean and above. My phone finally got the Android 4.1 update. The Network Service Discovery Manager is available starting from Android AP/Leve/16. This section discusses each of these different version schemes and how they relate to each other.Table 1-1 provides a reference to easily map between those version schemes. Platform Version The Android platform is versioned using the change significance version s6qenceehiershaiar83epearaegSyao8.Osc9asAg eme oid4.0.3 The first identifier in the platform version number denotes the major version number and is incremented only for releases with significant functionality changes.The second and third identifiers are for minor version numbers and they are incremented for minor changes and bug fixes.Based on that, an update from Android 3.2 to Android 4.0 indicates a major release,and an update from Android 4.0 to Android 4.0.1 represents a minor bug fix release At the time of this writing,the latest Android platfo m version is 5.0.The roid platf s gone throug a numbe r of updates ug fixes since the first commercial use of Android 1.0 on September 23,2008. Platform Codename As the target audience for the Android platform is not only developers,since April 2009,each major Android platform version has been released under a codename based on desserts such as KitKat,Jelly Bean,Ice Cream,and Lollipop. API Level Although the minor bug fix releases are usually transparent from the application developer's perspective,the major platform updates usually mean changes and additions to the Android framework APl
10 CHAPTER 1: Android Platform Android Versions When speaking of Android, you will often hear the same Android version being referred to in many different ways. This application requires Jelly Bean and above. My phone finally got the Android 4.1 update. The Network Service Discovery Manager is available starting from Android API Level 16. This section discusses each of these different version schemes and how they relate to each other. Table 1-1 provides a reference to easily map between those version schemes. Platform Version The Android platform is versioned using the change significance version scheme. The platform version number consists of two- or three-integer sequence identifiers that are separated by dots, such as Android 4.0.3. The first identifier in the platform version number denotes the major version number and is incremented only for releases with significant functionality changes. The second and third identifiers are for minor version numbers and they are incremented for minor changes and bug fixes. Based on that, an update from Android 3.2 to Android 4.0 indicates a major release, and an update from Android 4.0 to Android 4.0.1 represents a minor bug fix release. At the time of this writing, the latest Android platform version is 5.0. The Android platform has gone through a number of updates and bug fixes since the first commercial use of Android 1.0 on September 23, 2008. Platform Codename As the target audience for the Android platform is not only developers, since April 2009, each major Android platform version has been released under a codename based on desserts such as KitKat, Jelly Bean, Ice Cream, and Lollipop. API Level Although the minor bug fix releases are usually transparent from the application developer’s perspective, the major platform updates usually mean changes and additions to the Android framework API
CHAPTER 1:Android Platform 11 In order to make this concept easier to follow,the Android framework API is versioned separately from the Android platform through an integer identifier known as the API level.Each Android platform version supports exactly one API level,and the lower API levels are supported implicitly. On the Android Developers Portal,API documentation always provide the API level where the API was introduced,as shown in Table 1-1 in order to make the deve oper r aware of the API level requirement. Table 1-1.Android Release Dates,Platform Versions,Codenames,and API Levels Release Date Platform Version Platform Codename API Level September 2008 1.0 1 February 2009 1.1 April 2009 1.5 Cupcake 3 September 2009 1.6 Donut 4 October 2009 2.0 Eclair 5 December 2009 2.0.1 Eclair January 2010 2.1 Eclair May 2010 2.2-2.2.3 Froyo December 2010 2.3-2.3.2 Gingerbread 9 February 2011 2.3.3-2.3.7 Gingerbread 10 February 2011 3.0 Honeycomb 11 May 2011 3.1 Honeycomb 1 July 2011 3.2-3.2.6 Honeycomb 13 October 2011 4.0-4.0.2 Ice Cream Sandwich 14 December 2011 4.0.3-4.0.4 Ice Cream Sandwich 15 July 2012 4.1-4.1.2 Jelly Bean November 2012 4.2-4.2.2 Jelly Bean 1> July 2013 4.3-4.3.1 Jelly Bean 18 October 2013 4.4-4.4.4 KitKat 19 July 2014 4.4w KitKat with Wearable Extensions 20 November 2014 5.0 Lollipop 21
CHAPTER 1: Android Platform 11 In order to make this concept easier to follow, the Android framework API is versioned separately from the Android platform through an integer identifier known as the API level. Each Android platform version supports exactly one API level, and the lower API levels are supported implicitly. On the Android Developers Portal, API documentation always provide the API level where the API was introduced, as shown in Table 1-1 in order to make the developer aware of the API level requirement. Table 1-1. Android Release Dates, Platform Versions, Codenames, and API Levels Release Date Platform Version Platform Codename API Level September 2008 1.0 - 1 February 2009 1.1 - 2 April 2009 1.5 Cupcake 3 September 2009 1.6 Donut 4 October 2009 2.0 Éclair 5 December 2009 2.0.1 Éclair 6 January 2010 2.1 Éclair 7 May 2010 2.2–2.2.3 Froyo 8 December 2010 2.3–2.3.2 Gingerbread 9 February 2011 2.3.3–2.3.7 Gingerbread 10 February 2011 3.0 Honeycomb 11 May 2011 3.1 Honeycomb 12 July 2011 3.2–3.2.6 Honeycomb 13 October 2011 4.0–4.0.2 Ice Cream Sandwich 14 December 2011 4.0.3–4.0.4 Ice Cream Sandwich 15 July 2012 4.1–4.1.2 Jelly Bean 16 November 2012 4.2–4.2.2 Jelly Bean 17 July 2013 4.3–4.3.1 Jelly Bean 18 October 2013 4.4–4.4.4 KitKat 19 July 2014 4.4w KitKat with Wearable Extensions 20 November 2014 5.0 Lollipop 21
CHAPTER 1:Android Platform You can use Table 1-1 as a reference to map between these three different version schemes. The Android platform is very actively being developed.As shown in Table 1-1, s,the Android platform went through a large numbe of upo ate Android Platform Fragmentation By simply glancing through the release dates shown in Table 1-1,you might think that most of the Android devices out there must be running at least Android 4.4,as it has been out for a year;however,this is not true.Due to high fragmentation,the release dates do not pro ovide a clear view of the Android ecosystem Table 1-2 is the latest version distribution chart from Android Platform Versions Dashboard-based on the data collected in December 2014. Table 1-2.Android platform version distribution chart Platform Version Platform Codename API Level Distribution 2.2-2.2.3 Froyo 0.5% 2.3.3-2.3.7 Gingerbread 9 9.1% 4.0.3-4.0.4 Ice Cream Sandwich 15 7.8% 4.1-4.1.2 Jelly Bean 16 21.3% 4.2-4.2.2 Jelly Bean 20.4% 4.3-4.3.1 Jelly Bean 18 7.0% 4.4-4.4.4 KitKat 19 33.9% At the time of this writing,the latest version of the Android platform to be out for any length of time,Android 4.4,is only 33.9%of the overall Android user base.Developing an Android application targeting only API Level 19 will limit the that33.%portionof theentire Android user base There are 21 API levels that you should consider while developing your application;make sure to take the version distribution chart in to consideration.Although higher API levels provide additional functionality, they also determine the size of your audience. 2https://developer.android.com/about/dashboards/index.html
12 CHAPTER 1: Android Platform You can use Table 1-1 as a reference to map between these three different version schemes. The Android platform is very actively being developed. As shown in Table 1-1, over the course of four years, the Android platform went through a large number of update and bug fix releases. Android Platform Fragmentation By simply glancing through the release dates shown in Table 1-1, you might think that most of the Android devices out there must be running at least Android 4.4, as it has been out for a year; however, this is not true. Due to high fragmentation, the release dates do not provide a clear view of the Android ecosystem. Table 1-2 is the latest version distribution chart from Android Platform Versions Dashboard2 based on the data collected in December 2014. Table 1-2. Android platform version distribution chart Platform Version Platform Codename API Level Distribution 2.2–2.2.3 Froyo 8 0.5% 2.3.3–2.3.7 Gingerbread 9 9.1% 4.0.3–4.0.4 Ice Cream Sandwich 15 7.8% 4.1–4.1.2 Jelly Bean 16 21.3% 4.2–4.2.2 Jelly Bean 17 20.4% 4.3–4.3.1 Jelly Bean 18 7.0% 4.4–4.4.4 KitKat 19 33.9% 2https://developer.android.com/about/dashboards/index.html. At the time of this writing, the latest version of the Android platform to be out for any length of time, Android 4.4, is only 33.9% of the overall Android user base. Developing an Android application targeting only API Level 19 will limit the application’s audience only to that 33.9% portion of the entire Android user base. There are 21 API levels that you should consider while developing your application; make sure to take the version distribution chart in to consideration. Although higher API levels provide additional functionality, they also determine the size of your audience