Android Overview Most of the material in this section comes from http://developer.android.com/guide/
Android Overview A software stack for mobile devices Developed and managed by Open Handset Alliance Open-sourced under Apache License Key Applications Middleware Operating System (Linux Kernel 2.6) COMP 355 (Muppala) Android Overview 2
Android Features Application framework enabling reuse and replacement of components Dalvik virtual machine optimized for mobile devices 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) Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE Source: http://developer.android.com COMP 355 (Muppala) Android Overview 3
Android Platform Versions Moving target, new platforms released regularly COMP 355 (Muppala) Android Overview 4
Android Architecture COMP 355 (Muppala) Android Overview 5
Android Architecture - Applications Android ships with a set of core applications: Email Client SMS Program Calendar Maps Browser Contacts All applications are written using the Java language. COMP 355 (Muppala) Android Overview 6
Android Architecture Application Framework Enabling and simplifying the reuse of components Developers have full access to the same framework APIs used by the core applications. Application architecture designed to simplify reuse of components Users are allowed to replace components. COMP 355 (Muppala) Android Overview 7
Android Architecture Application Framework Set of services and features Feature View System Content Provider Resource Manager Notification Manager Activity Manager Role Used to build an application, including lists, grids, text boxes, buttons, and embedded web browser Enabling applications to access data from other applications or to share their own data Providing access to non-code resources such as localized strings, graphics, and layout files Enabling all applications to display custom alerts in the status bar Manages the lifecycle of applications and provides a common navigation backstack COMP 355 (Muppala) Android Overview 8
Android Architecture - Libraries Includes a set of C/C++ libraries used by various components of the Android system Exposed to developers through the Android application framework Features System C Library (Bionic) a version of libc Media Libraries supporting playback and recording of popular audio/video formats Surface Manager (Surface Flinger) Audio Manager (Audio Flinger) LibWebCore (WebKit) SGL 3D Libraries: Open GL ES WebKit browser support SQLite COMP 355 (Muppala) Android Overview 9
Android Architecture - Runtime Core Libraries Provides most of the functionality available in the core libraries of the Java programming language APIs Data Structures Utilities File Access Network Access Graphics Etc COMP 355 (Muppala) Android Overview 10
Android Architecture Runtime (Contd.) Every Android application runs in its own process, with its own instance of the Dalvik Virtual Machine Dalvik Virtual Machine Dalvik VM has been written so that a device can run multiple VMs efficiently Register-based virtual machine COMP 355 (Muppala) Android Overview 11
Android Architecture Runtime (Contd.) Dalvik Virtual Machine (Cont) Executes files in the Dalvik Executable (.dex) format, which is optimized for minimal memory footprint Runs classes compiled by a Java language compiler transformed into the.dex format a.java Java compiler a.class Dx tool a.dex Relies on the Linux kernel for underlying functionality such as threading and low-level memory management COMP 355 (Muppala) Android Overview 12
Android Architecture Linux Kernel Android relies on Linux Kernel 2.6 for core system services Memory Management Process Management Network Stack Driver Model Security The Kernel acts as an abstraction layer between the hardware and the rest of the software stack COMP 355 (Muppala) Android Overview 13
Android Application Fundamentals
Android Applications Android applications are written in Java The compiled Java code (along with any data and resource files required by the application) is bundled by the aapt tool into an Android package (.apk).apk package Data files Java classes Resources COMP 355 (Muppala) Android Overview 15
Android Applications Each Android application lives in its own world: Runs in its own Linux process Started when any of the application code needs to be executed Shuts down when no longer needed or system resources are required by other applications Each process has its own virtual machine (sandboxing) Application code runs in isolation from all other applications Each application assigned a unique Linux user ID COMP 355 (Muppala) Android Overview 16
Application Components One application can make use of elements of other applications Applications are composed of parts (components) that can be started up when the need arises, and instantiate the Java objects for that part Android applications do not have a single entry point (e.g. no main() function). Essential components that the system can instantiate and run as needed COMP 355 (Muppala) Android Overview 17
Application Components Four basic components: Activities, Services, Broadcast Receivers, Content Providers Activities Services Application Components Broadcast Receivers Content Providers COMP 355 (Muppala) Android Overview 18
Activity An activity is visual UI for one endeavour the user can undertake: Extends the Activity base class Displays user interface controls (views) Provides for user interaction COMP 355 (Muppala) Android Overview 19
Activity (Contd.) An application typically consists of one or more activities: Each activity has a default window to draw in (the UI) One activity usually marked as the main activity (started when the application begins) Moving from one activity to another is accomplished by having the current activity start the next one An activity may return a result to the previous activity. Details of activities specified in the Application s Android Manifest file COMP 355 (Muppala) Android Overview 20
Example Android Manifest File <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cse.ust.buttonfun" android:versioncode="1" android:versionname="1.0" > Your package name and version of code <uses-sdk android:minsdkversion="15" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".buttonfunactivity" 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> Your supported Android version Your application and activity settings </manifest> COMP 355 (Muppala) Android Overview 21
Service A service runs in the background for an indefinite period time. Example: play music, network download, etc Does not have a user interface extends the Service base class. We can bind to a running service (or start the service if it's not already running)
Broadcast Receivers Receives and reacts to broadcast announcements (Intents) Many broadcasts originate in system code. E.g. announcements that a picture is taken, that the time zone has changed, that the battery is low, etc. Applications can also initiate broadcasts. E.g. to let other applications know that some data has been downloaded to the device and is available for them to use Do not have a user interface May start an activity in response to the received broadcast May also use notifications to alert the user COMP 355 (Muppala) Android Overview 23
Content Providers Makes a specific set of the application's data available to other applications Data can be stored in the file system, in an SQLite, or in any other manner that makes sense extends the ContentProvider base class to implement a standard set of methods that enable other applications to retrieve and store data of the type it controls Applications do not call these methods directly. They use a ContentResolver object and call its methods instead A ContentResolver can talk to any content provider COMP 355 (Muppala) Android Overview 24