Android

82
What is Android? Android is a software stack for mobile devices that includes an operating system, middleware and key applications. TheAndroid SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language. 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 Android Architecture The following diagram shows the major components of the Android operating system. Each section is

Transcript of Android

What is Android?Android is a software stack for mobile devices that includes an operating system, middleware and key applications. TheAndroid SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.

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

Android ArchitectureThe following diagram shows the major components of the Android operating system. Each section is described in more detail below.

ApplicationsAndroid will ship with a set of core applications including an email client, SMS program, calendar, maps, browser, contacts, and others. All applications are written using the Java programming language.

Application FrameworkBy providing an open development platform, Android offers developers the ability to build extremely rich and innovative applications. Developers are free to take advantage of the device hardware, access location information, run background services, set alarms, add notifications to the status bar, and much, much more. Developers have full access to the same framework APIs used by the core applications. The application architecture is designed to simplify the reuse of components; any application can publish its capabilities and any other application may then make use of those capabilities (subject to security constraints enforced by the framework). This same mechanism allows components to be replaced by the user. Underlying all applications is a set of services and systems, including:

A rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files A Notification An Activity

Manager that enables all applications to display custom alerts in the status bar Manager that manages the lifecycle of applications and provides a common navigation backstack

For more details and a walkthrough of an application, see the Notepad Tutorial.

LibrariesAndroid includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework. Some of the core libraries are listed below:

System C library - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices Media Libraries - based on PacketVideo's OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG Surface Manager - manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications LibWebCore - a modern web browser engine which powers both the Android browser and an embeddable web view SGL - the underlying 2D graphics engine 3D libraries - an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer FreeType - bitmap and vector font rendering SQLite - a powerful and lightweight relational database engine available to all applications

Android RuntimeAndroid includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language. Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool. The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management.

Linux KernelAndroid relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. The kernel also acts as an abstraction layer between the hardware and the rest of the software stack.

VERSIONS OF ANDROIDAndroid 1.5 Platform Codename: Cupcake

API Level: 3 Android 1.5 is a major platform release deployable to Android-powered handsets starting in May 2009. The release includes new features for users and developers, as well as changes in the Android framework API. For developers, the Android 1.5 platform is available as a downloadable component for the Android SDK. The downloadable platform includes a fully compliant Android library and system image, as well as a set of emulator skins, sample applications, and more. The downloadable platform is fully compliant and includes no external libraries. To get started developing or testing against the Android 1.5 platform, use the Android SDK and AVD Manager tool to download the platform into your Android 1.6 or later SDK.

API Level The Android 1.5 platform delivers an updated version of the framework API. The Android 1.5 API is assigned an integer identifier 3 that is stored in the system itself. This identifier, called the "API Level", allows the system to correctly determine whether an application is compatible with the system, prior to installing the application. To use APIs introduced in Android 1.5 in your application, you need to set the proper value, "3", in theandroid:minSdkVersion attributes of the element in your application's manifest. For more information about how to use API Level, see the API Levels document.

Framework API Changes The sections below provide information about the application framework API provided by the Android 1.5 platform.

UI framework

Framework for easier background/UI thread interaction New SlidingDrawer widget New HorizontalScrollview widget

AppWidget framework

APIs for creating secure home screen AppWidgets. For information about how to use AppWidgets, see the Developer's Guide AppWidgets documentation. Also see Introducing home screen widgets and the AppWidget framework on the Android Developer's Blog. APIs for populating Live Folders with custom content.

Media framework

Raw audio recording and playback APIs Interactive MIDI playback engine Video recording APIs for developers (3GP format) Video and photo sharing Intents Media search Intent

Input Method framework

Input Method Service framework Text-prediction engine Ability to provide downloadable IMEs to users

Application-defined hardware requirements Applications can now use a new element in their manifest files, to indicate to the Android system what hardware features they require in order to function properly. For example, an application might use the element to specify that it requires a physical keyboard or a particular navigation device, such as a trackball. Prior to installing the application, the Android system checks the attributes defined for the element and allows the installation to continue only if the required hardware is present. Speech recognition framework

Support for using speech recognition libraries via Intent. See RecognizerIntent.

Miscellaneous API additions

LocationManager - Applications can get location change updates via Intent WebView - Touch start/end/move/cancel DOM event support Redesigned Sensor Manager APIs GLSurfaceView - convenience framework for creating OpenGL applications Broadcast Intent for app update install succeeded - for smoother app upgrade experience

Built-in Applications The system image included in the downloadable platform provides these built-in applications:

Alarm Clock Browser Calculator Camcorder Camera Contacts Custom Locale (developer app) Dev Tools (developer app)

Dialer Email Gallery IME for Japanese text input Messaging Music Settings Spare Parts (developer app)

Emulator Skins The downloadable platform includes a set of emulator skins that you can use for modeling your application in different screen sizes and resolutions. The emulator skins are:

QVGA-P (240x320, low density, small screen) QVGA-L (320x480, low density, small screen) HVGA (320x480, medium density, normal screen) HVGA-P (320x480, medium density, normal screen) HVGA-L (320x480, medium density, normal screen)

Android 1.6 Platform Codename: DonutAPI Level: 4 Android 1.6 is a minor platform release deployable to Android-powered handsets since October 2009. The platform includes new features for users and developers, as well as changes in the Android framework API. For developers, a new release of the Android 1.6 platform is available as a downloadable component for the Android SDK. The platform Android 1.6 r2 includes a fully compliant Android library and system image, as well as a set of emulator skins, sample applications, and minor development updates. The downloadable platform is fully compliant (API Level 4) and includes no external libraries. To get started developing or testing against the Android 1.6 platform, use the Android SDK and AVD Manager tool to download the latest Android 1.6 platform into your Android 1.6 or later SDK.

API Level The Android 1.6 platform delivers an updated version of the framework API. The Android 1.6 API is assigned an integer identifier 4 that is stored in the system itself. This identifier, called the "API Level", allows the system to correctly determine whether an application is compatible with the system, prior to installing the application. To use APIs introduced in Android 1.6 in your application, you need to set the proper value, "4", in theandroid:minSdkVersion attributes of the element in your application's manifest. For more information about how to use API Level, see the API Levels document.

Framework API Changes The sections below provide information about the application framework API provided by the Android 1.6 platform.

UI framework

New classes in android.view.animation to control the behavior of animations: o AnticipateInterpolator o AnticipateOvershootInterpolator o BounceInterpolator o OvershootInterpolator New XML attribute android:onClick to specify a View's View.OnClickListener from a layout file. New support for dealing with varying screen densities. Density information is associated with Bitmap and Canvas for performing the correct scaling. The framework will automatically scale bitmaps and nine-patches based on the density the resource was found under and the density of the screen, etc.

To use APIs introduced in Android 1.6 in your application, you need to set the proper value, "4", in the attributes of the element in your application's manifest. Search framework

Applications can now expose relevant content to users as search suggestions in the Quick Search Box, a new device-wide search capability that is accessible from the home screen. To support this, the search framework adds new attributes to the searchable metadata file. For complete information, see the SearchManager documentation.

Accessibility framework

New android.accessibility package that includes classes for capturing accessibility events and forwarding them to an AccessibilityService handler. New AccessibilityService package that lets your application track user events and provide visual, audible, or haptic feedback to the user.

Gesture input

New gesture API for creating, recognizing, loading, and saving gestures.

Text-to-speech

New android.speech.tts package provides classes for synthesizing speech from text, for immediate playback or to create a sound file.

Graphics

Classes in android.graphics now support scaling for different screen densities.

Telephony

New SmsManager and other classes for sending and receiving SMS messages.

Utilities

New DisplayMetrics fields for determining the density of the current device screen.

Android Manifest elements

New element lets you specify the device screen sizes that your application is designed and tested to support, where "size" is a combination of resolution and density. If your application is run on a device whose screen size is not specified in the element, the system displays the application in compatibility mode, which performs best-effort scaling of the application UI to match the resolution and density of the screen.

The attributes available for defining an application's screen support are:

o o o o o

smallScreen: Boolean value that indicates whether the application is designed to run on devices with small screens. Examples: QVGA low density; VGA high density. normalScreens: Boolean value that indicates whether the application is designed to run on devices with normal screens. Examples: WQVGA low density; HVGA medium density; WVGA high density. largeScreens: Boolean value that indicates whether the application is designed to run on devices with significantly larger screens, such that special care may be required on the application's part to make proper use of the screen area. Examples: VGA medium density; WVGA medium density. anyDensity: Boolean value that indicates whether the application can accommodate any screen density. resizable: Boolean value that indicates whether the application can expand its layout to fit slightly larger screens.

New element lets an application specify hardware (or other) features that it requires to function normally. When an application specifies such features, the system allows the application to be installed only on devices that offer the required features. The element supports these attributes: o name: The name of the feature required by the application. Currently accepts "android.hardware.camera" and "android.hardware.camera.autofocus" values, which specify that a camera and camera autofocus are required, respectively. o glEsVersion: Indicates the minimum version of OpenGL ES required. New attributes for the element: o targetSdkVersion: Indicates the API Level that the application is targeting. It is able to run on older versions (down to minSdkVersion), but was explicitly tested to work with the version specified here. Specifying this version allows the platform to disable compatibility code that is not required or enable newer features that are not available to older applications. o maxSdkVersion: Indicates the maximum API Level on which an application is designed to run. Important: Please read the documentation before using this attribute.

New permissions

CHANGE_WIFI_MULTICAST_STATE: Allows applications to enter Wi-Fi Multicast mode. GLOBAL_SEARCH: Allows the global search system to access the data of a specified content provider. INSTALL_LOCATION_PROVIDER: Allows an application to install a location provider into the Location Manager. READ_HISTORY_BOOKMARKS: Allows an application to read (but not write) the user's browsing history and bookmarks.

WRITE_HISTORY_BOOKMARKS: Allows an application to write (but not read) the user's browsing history and bookmarks. WRITE_EXTERNAL_STORAGE: Allows an application to write to external storage. Applications using API Level 3 and lower will be implicitly granted this permission (and this will be visible to the user); Applications using API Level 4 or higher must explicitly request this permission.

API differences report For a detailed view of API changes in Android 1.6 (API Level 4), as compared to the previous version, see the API Differences Report.

Emulator Skins The downloadable platform includes a set of emulator skins that you can use for modeling your application in different screen sizes and resolutions. The emulator skins are:

QVGA (240x320, low density, small screen) HVGA (320x480, medium density, normal screen) WVGA800 (480x800, high density, normal screen) WVGA854 (480x854 high density, normal screen)

.

Android 2.1 Platform Codename: EclairAPI Level: 7 Android 2.1 is a minor platform release deployable to Android-powered handsets starting in January 2010. This release includes new API changes and bug fixes. For information on changes, see the Framework API section. For developers, the Android 2.1 platform is available as a downloadable component for the Android SDK. The downloadable platform includes a fully compliant Android library and system image, as well as a set of emulator skins, sample applications, and more. The downloadable platform includes no external libraries. To get started developing or testing against the Android 2.1 platform, use the Android SDK and AVD Manager tool to download the platform into your SDK. For more information, see Adding SDK Components.

API Level The Android 2.1 platform delivers an updated version of the framework API. The Android 2.1 API is assigned an integer identifier 7 that is stored in the system itself. This identifier, called the "API Level", allows the system to correctly determine whether an

application is compatible with the system, prior to installing the application. To use APIs introduced in Android 2.1 in your application, you need to set the proper value, "7", in theandroid:minSdkVersion attributes of the element in your application's manifest.

Framework API Changes The sections below provide information about changes made to the application framework API provided by the Android 2.1 platform. Live Wallpapers The following additions provide APIs for you to develop animated wallpapers:

New android.service.wallpaper package. New WallpaperInfo class. Updated WallpaperManager.

Telephony

New SignalStrength class provides information about the device's current network signal. This can be acquired from the new onSignalStrengthsChanged(SignalStrength) callback. New onDataConnectionStateChanged(int, int) callback.

Views

New View methods isOpaque() and onDrawScrollBars(Canvas). New RemoteViews methods addView(int, RemoteViews) and removeAllViews(int). New ViewGroup methods isChildrenDrawingOrderEnabled() andsetChildrenDrawingOrderEnabled(boolean).

WebKit

New WebStorage methods to manipulate web storage databases. New GeolocationPermissions methods to get Geolocation permissions from, and set them on the WebView. New WebSettings methods to manage settings for app cache, web storage, and zooming based on screen density. New WebChromeClient methods for handling video, browsing history, custom Views, app cache limits, and more.

Built-in Applications The system image included in the downloadable platform provides these built-in applications:

Alarm Clock

Browser Gallery IMEs for Japanese, Chinese, and Latin text input Messaging Music Phone Settings Spare Parts (developer app) Calculator Camera Contacts Custom Locale (developer app) Dev Tools (developer app) Email

Locales The system image included in the downloadable SDK platform provides a variety of built-in locales. In some cases, region-specific strings are available for the locales. In other cases, a default version of the language is used. The languages that are available in the Android 3.0 system image are listed below (with language_country/region locale descriptor).

Arabic, Egypt (ar_EG) Arabic, Israel (ar_IL) Bulgarian, Bulgaria (bg_BG) Catalan, Spain (ca_ES) Czech, Czech Republic (cs_CZ) Danish, Denmark(da_DK) German, Austria (de_AT) German, Switzerland (de_CH) German, Germany (de_DE) German, Liechtenstein (de_LI) Greek, Greece (el_GR) English, Australia (en_AU) English, Canada (en_CA) English, Britain (en_GB) English, Ireland (en_IE) English, India (en_IN) English, New Zealand (en_NZ) English, Singapore(en_SG) English, US (en_US) English, Zimbabwe (en_ZA) Spanish (es_ES) Spanish, US (es_US) Finnish, Finland (fi_FI) French, Belgium (fr_BE) French, Canada (fr_CA) French, Switzerland (fr_CH)

Croatian, Croatia (hr_HR) Hungarian, Hungary (hu_HU) Indonesian, Indonesia (id_ID) Italian, Switzerland (it_CH) Italian, Italy (it_IT) Japanese (ja_JP) Korean (ko_KR) Lithuanian, Lithuania (lt_LT) Latvian, Latvia (lv_LV) Norwegian bokml, Norway (nb_NO) Dutch, Belgium (nl_BE) Dutch, Netherlands (nl_NL) Polish (pl_PL) Portuguese, Brazil (pt_BR) Portuguese, Portugal (pt_PT) Romanian, Romania (ro_RO) Russian (ru_RU) Slovak, Slovakia (sk_SK) Slovenian, Slovenia (sl_SI) Serbian (sr_RS) Swedish, Sweden (sv_SE) Thai, Thailand (th_TH) Tagalog, Philippines (tl_PH) Turkish, Turkey (tr_TR) Ukrainian, Ukraine (uk_UA) Vietnamese, Vietnam (vi_VN) Chinese, PRC (zh_CN) Chinese, Taiwan (zh_TW)

French, France (fr_FR) Hebrew, Israel (he_IL) Hindi, India (hi_IN)

Android 2.2 Platform Codename: FroyoAPI Level: 8 Android 2.2 is a minor platform release including user features, developer features, API changes, and bug fixes. For information on developer features and API changes, see the Framework APIsection. For developers, the Android 2.2 platform is available as a downloadable component for the Android SDK. The downloadable platform includes a fully compliant Android library and system image, as well as a set of emulator skins, sample applications, and more. The downloadable platform includes no external libraries. To get started developing or testing against the Android 2.2 platform, use the Android SDK and AVD Manager tool to download the platform into your SDK.

API Level The Android 2.2 platform delivers an updated version of the framework API. The Android 2.2 API is assigned an integer identifier 8 that is stored in the system itself. This identifier, called the "API Level", allows the system to correctly determine whether an application is compatible with the system, prior to installing the application. To use APIs introduced in Android 2.2 in your application, you need to set the proper value, "8", in theandroid:minSdkVersion attributes of the element in your application's manifest.

Framework API Changes The sections below provide information about changes made to the application framework API provided by the Android 2.2 platform. App installation on external storage media The Android platform now allows applications to request installation onto the device's external storage media (such as the SD card), as an alternative to installation onto the device's internal memory. Application developers can express the preferred installation location for their applications by means of a new attribute of in the manifest file, android:installLocation. The attribute supports three values: "internalOnly","preferExternal", and "auto". At install time, the system checks the value of android:installLocation and installs the application .apk according to the preferred location, if possible. If the application has requested external installation, the system installs it into a private, encrypted partition in the external media. Once an application .apk is installed externally, the system lets the user change the storage location of the .apk and move it onto the device's internal memory if needed (and vice versa), through Manage Applications in the user settings. By default, the system installs all applications onto the device's internal memory, except for those that explicitly request external installation. This means that the system will always install legacy applications onto internal memory, since they do not have access to the android:installLocation attribute. However, it is possible to configure and compile a legacy application such that it is installed internally on older versions of the platform and externally on Android 2.2 and later platforms, if necessary. Note that requesting installation onto the device's external media is not suitable for all applications, particularly because the external media may be removable and unmounting/remounting may disrupt the user experience and system settings. For more information about setting a preferred install location for your application, including a discussion of what types of applications should and should not request external installation, please read the App Install Location document. Data backup

The platform now provides a generalized backup service that applications can use to backup and restore user data, to ensure that users can maintain their data when switching devices or reinstalling the application. The Backup Manager handles the work of transporting the application data to and from the backup storage area in the cloud. The Backup Manager can store any type of data, from arbitrary data to files, and manages backup and restore operations in an atomic manner. For more information, see Data Backup.

Graphics

New OpenGL ES 2.0 APIs in android.opengl.GLES20. New ETC1, ETC1Util, and ETC1Util.ETC1Texture classes and utility methods for using ETC1 for texture compression. New ImageFormat class. New YUV image format API to enable compression from YUV to JPEG and manipulation of YUV data.

Media

New APIs in android.media.AudioManager for managing audio focus, transport control, transient loss of audio focus, ducking. New broadcast intent for routing audio to SCO ACTION_SCO_AUDIO_STATE_CHANGED with extras indicating new state. New APIs in SoundPool to detect completion of sound-loading. New APIs in SoundPool for auto pause and resume. New APIs in MediaRecorder for specifying audio settings for number of channels, encoding and sampling rates, sampling rate. New APIs for adding files to the media database, so that they are automatically scanned. SeeMediaScannerConnection.scanFile and MediaScannerConnection.OnScanCompletedListener.

Speech recognition and third-party recognition engines

The platform provides new speech-recognition APIs that allow applications to have a richer interaction with the available voice recognizer. For example, the APIs are sufficient to integrate voice recognition deeply into an IME. The platform also provides a RecognitionService base class that lets third-party developers create plug-in recognition engines. New RecognitionListener interface to receive callbacks. New RecognizerIntent extras that let a requester app specify details as preferred language, minimum length in milliseconds, and so on.

Camera and camcorder

Changes to camera preview API to improve efficieny of preview pipeline. New display orientation for camera (it can now work in portrait orientation). New APIs in android.hardware.Camera for managing zoom level. New APIs android.hardware.Camera.Parameters for querying and setting device camera settings such as focal length, exposure, zoom level, view angle, and others. New thumbnail utility for video and image thumbnails. New CamcorderProfile and CamcorderProfile classes enable apps to determine device hardware camera capablities. New support in android.media.ExifInterface for retrieving GPS and focal length.

Device policy manager New device policy management APIs allow developers to write "device administrator" applications that can control security features of the device, such as the minimum password strength, data wipe, and so on. Users can select the administrators that are enabled on their devices. For more information, see the android.app.admin classees or the example application code in DeviceAdminSample.java. UI Framework

New UI modes "car mode" and "night mode" and UiModeManager let applications adjust their application UI for specific user modes. New ScaleGestureDetector that lets Views detect and handle transformation gestures that involve more than one pointer (multitouch) using the supplied MotionEvents. Improvements in the way that multitouch events are reported in MotionEvent objects. The layout attribute fill_parent is renamed to match_parent. This affects both XML and Java code (seeViewGroup.LayoutParams). Note that the platform will continue to honor uses of fill_parent in legacy applications. New layout attributes tabStripEnabled, tabStripRight, and tabStripLeft let developers customize the bottom strip of TabWidgets. Better support for managed dialogs in Activity.

Accounts and sync

New method AddPeriodicSync() lets you schedule a periodic sync with a specific account, authority, and extras at the given frequency.

New manifest elements and attributes

For specifying the application's preferred install location (see App Installation on External Storage Media, above): o New android:installLocation attribute of the element. Specifies the default install location defined by an application. For managing user data backup (see Backup manager, above, for more information): o New android:backupAgent attribute of the element. Specifies the component name of the BackupAgent subclass provided by the application to handle backup/restore operations, if any. o New android:restoreAnyVersion attribute of the element. Boolean value that indicates whether the application is prepared to attempt a restore of any backed-up dataset, even if the backup is apparently from a newer version of the application than is currently installed on the device. For managing the platform's JIT compiler: o New android:vmSafeMode attribute of the element. Boolean value that specifies whether to disable JIT compiler optimizations when running the application.

Permissions

android.permission.BIND_DEVICE_ADMIN Any device administration broadcast receiver must require this permission, to ensure that only the system can interact with it. android.permission.KILL_BACKGROUND_PROCESSES Allows an application to callkillBackgroundProcesses(String).

android.permission.BIND_WALLPAPER Any WallpaperService must require this permission, to ensure that only the system can interact with it. android.permission.SET_TIME Allows an application to set the system time.

Built-in Applications The system image included in the downloadable platform provides these built-in applications:

Alarm Clock Browser Calculator Camera Contacts Custom Locale (developer app) Dev Tools (developer app)

Gallery IMEs for Japanese, Chinese, and Latin text input Messaging Music Phone Settings Spare Parts (developer app)

Email

Android 2.3 Platform Codename: GingerbreadAPI Level: 9 For developers, the Android 2.3 platform is available as a downloadable component for the Android SDK. The downloadable platform includes an Android library and system image, as well as a set of emulator skins and more. The downloadable platform includes no external libraries. To get started developing or testing against Android 2.3, use the Android SDK Manager to download the platform into your SDK. For more information, see Adding SDK Components. If you are new to Android, download the SDK Starter Package first. Dependencies: Requires SDK Tools r8 or higher.

API Overview The sections below provide a technical overview of what's new for developers in 2.3, including new features and changes in the framework API since the previous version. SIP-based VoIP The platform now includes a SIP protocol stack and framework API that lets developers build internet telephony applications. Using the API, applications can offer voice calling features without having to manage sessions, transport-level communication, or audio these are handled transparently by the platform's SIP API and services. The SIP API is available in the android.net.sip package. The key class is SipManager, which applications use to set up and manage SIP profiles, then initiate audio calls and receive audio calls. Once an audio call is established, applications can mute calls, turn on speaker mode, send DTMF tones, and more. Applications can also use the SipManager to create generic SIP connections. The platforms underlying SIP stack and services are available on devices at the discretion of the manufacturer and associated carrier. For this reason, applications should use the isApiSupported() method to check whether SIP support is available, before exposing calling functionality to users. To use the SIP API, applications must request permission from the user by declaring and in their manifest files. Additionally, developers can request filtering on Android Market, such that their applications are not discoverable to users whose devices do not include the platforms SIP stack and services. To request filtering, add and to the application manifest. To look at a sample application that uses the SIP API, see SIP Demo. Near Field Communications (NFC)

Android 2.3 includes an NFC stack and framework API that lets developers read NDEF tags that are discovered as a user touches an NFC-enabled device to tag elements embedded in stickers, smart posters, and even other devices. The platform provides the underlying NFC services that work with the device hardware to discover tags when they come into range. On discovering a tag, the platform notifies applications by broadcasting an Intent, appending the tag's NDEF messages to the Intent as extras. Applications can create Intent filters to recognize and handle targeted tags and messages. For example, after receiving a tag by Intent, applications extract the NDEF messages, store them, alert the user, or handle them in other ways. The NFC API is available in the android.nfc package. The key classes are:

NfcAdapter, which represents the NFC hardware on the device. NdefMessage, which represents an NDEF data message, the standard format in which "records" carrying data are transmitted between devices and tags. Applications can receive these messages from ACTION_TAG_DISCOVEREDIntents. NdefRecord, delivered in an NdefMessage, which describes the type of data being shared and carries the data itself.

NFC communication relies on wireless technology in the device hardware, so support for the platform's NFC features on specific devices is determined by their manufacturers. To determine the NFC support on the current device, applications can call isEnabled() to query the NfcAdapter. The NFC API is always present, however, regardless of underlying hardware support. To use the NFC API, applications must request permission from the user by declaring in their manifest files. Additionally, developers can request filtering on Android Market, such that their applications are not discoverable to users whose devices do not support NFC. To request filtering, add to the application's manifest. To look at a sample application that uses the NFC API, see NFCDemo. Gyroscope and other sensors Android 2.3 adds platform and API support for several new sensor reading types gyroscope, rotation vector, linear acceleration, gravity, and barometer. Developers can use the new sensor readings to create applications that respond quickly and smoothly to precise changes in device position and motion. The Sensor API reports gyroscope and other sensor changes to interested applications, whether they are running on the application framework or in native code. Note that the specific set of hardware sensors available on any given device varies at the discretion of the device manufacturer. Developers can request filtering in Android Market, such that their applications are not discoverable to users whose devices do not offer a gyroscope sensor. To do so, add to the application manifest. For API details, see Sensor. Multiple cameras support Applications can now make use of any cameras that are available on a device, for either photo or video capture. The Cameralets applications query for the number of cameras available and the unique characteristics of each.

New Camera.CameraInfo class stores a camera's positional characteristics (orientation, front-facing or back-facing). New getNumberOfCameras() and getCameraInfo() methods in the Camera class let applications query for the cameras available and open the camera that they need. New get() method lets applications retrieve a CamcorderProfile for a specific camera. New getJpegEncodingQualityParameter() lets applications obtain the still-image capture quality level for a specific camera.

To look at sample code for accessing a front-facing camera, see CameraPreview.java in the ApiDemos sample application. The Camera API also adds:

New parameters for cameras, including focus distance, focus mode, and preview fps maximum/minimum. NewgetFocusDistances(), getPreviewFpsRange(), and getSupportedPreviewFpsRange() for getting camera parameters, as well as setPreviewFpsRange() for setting preview framerate.

Mixable audio effects

The platform's media framework adds support for new per-track or global audio effects, including bass boost, headphone virtualization, equalization, and reverb.

New android.media.audiofx package provides the API to access audio effects. New AudioEffect is the base class for controlling audio effects provided by the Android audio framework. New audio session ID that lets an application associate a set of audio effects with an instance of AudioTrack orMediaPlayer. New AudioTrack class constructor that lets you create an AudioTrack with a specific session ID. NewattachAuxEffect(), getAudioSessionId(), and setAuxEffectSendLevel() methods. New attachAuxEffect(), getAudioSessionId(), setAudioSessionId(int), andsetAuxEffectSendLevel() methods and supporting types.

To look at sample code for audio effects, see AudioFxDemo.java in the ApiDemos sample application. The media framework also adds:

New support for altitude tag in EXIF metadata for JPEG files. New method getAltitude() method to retrieve the value of the EXIF altitude tag. New setOrientationHint() method lets an application tell MediaRecorder of the orientation during video capture.

Download manager The platform includes a new DownloadManager system service that handles long-running HTTP downloads. Applications can request that a URI be downloaded to a particular destination file. The DownloadManager will conduct the download in the background, taking care of HTTP interactions and retrying downloads after failures or across connectivity changes and system reboots.

Applications can obtain an instance of the DownloadManager class by calling getSystemService(String) and passing DOWNLOAD_SERVICE. Applications that request downloads through this API should register a broadcast receiver for ACTION_NOTIFICATION_CLICKED, to appropriately handle when the user clicks on a running download in a notification or from the Downloads UI. The DownloadManager.Request class lets an application provide all the information necessary to request a new download, such as request URI and download destination. A request URI is the only required parameter. Note that the default download destination is a shared volume where the system can delete your file if it needs to reclaim space for system use. For persistent storage of a download, specify a download destination on external storage (seesetDestinationUri(Uri)). The DownloadManager.Query class provides methods that let an application query for and filter active downloads.

StrictMode To help developers monitor and improve the performance of their applications, the platform offers a new system facility calledStrictMode. When implemented in an application, StrictMode catches and notifies the developer of accidental disk or network activity that could degrade application performance, such as activity taking place on the application's main thread (where UI operations are received and animations are also taking place). Developers can evaluate the network and disk usages issues raised in StrictMode and correct them if needed, keeping the main thread more responsive and preventing ANR dialogs from being shown to users.

StrictMode is the core class and is the main integration point with the system and VM. The class provides convenience methods for managing the thread and VM policies that apply to the instance. StrictMode.ThreadPolicy and StrictMode.VmPolicy hold the policies that you define and apply to thread and VM instances.

For more information about how to use StrictMode to optimize your application, see the class documentation and sample code at android.os.StrictMode. UI Framework

Support for overscroll o New support for overscroll in Views and Widgets. In Views, applications can enable/disable overscroll for a given view, set the overscoll mode, control the overscroll distance, and handle the results of overscrolling. o In Widgets, applications can control overscroll characteristics such as animation, springback, and overscroll distance. For more information, see android.view.View and android.widget.OverScroller. o ViewConfiguration also provides methods getScaledOverflingDistance() andgetScaledOverscrollDistance(). o New overScrollMode, overScrollFooter, and overScrollHeader attributes for elements, for controlling overscroll behavior. Support for touch filtering o New support for touch filtering, which lets an application improve the security of Views that provide access to sensitive functionality. For example, touch filtering is appropriate to ensure the security of user actions such as granting a permission request, making a purchase, or clicking on an advertisement. For details, see the View class documentation. o New filterTouchesWhenObscured attribute for view elements, which declares whether to filter touches when the view's window is obscured by another visible window. When set to "true", the view will not receive touches whenever a toast, dialog or other window appears above the view's window. Refer to View security documentation for details.

To look at sample code for touch filtering, see SecureView.java in the ApiDemos sample application.

Improved event management o New base class for input events, InputEvent. The class provides methods that let applications determine the meaning of the event, such as by querying for the InputDevice from which the event orginated. The KeyEvent andMotionEvent are subclasses of InputEvent. o New base class for input devices, InputDevice. The class stores information about the capabilities of a particular input device and provides methods that let applications determine how to interpret events from an input device. Improved motion events o The MotionEvent API is extended to include "pointer ID" information, which lets applications to keep track of individual fingers as they move up and down. The class adds a variety of methods that let an application work efficiently with motion events. o The input system now has logic to generate motion events with the new pointer ID information, synthesizing identifiers as new pointers are down. The system tracks multiple pointer IDs separately during a motion event, and ensures proper continuity of pointers by evaluating at the distance between the last and next set of pointers. Text selection controls o A new setComposingRegion method lets an application mark a region of text as composing text, maintaining the current styling. A getSelectedText method returns the selected text to the application. The methods are available in BaseInputConnection, InputConnection, and InputConnectionWrapper. o New textSelectHandle, textSelectHandleLeft, textSelectHandleRight, andtextSelectHandleWindowStyle attributes for , for referencing drawables that will be used to display text-selection anchors and the style for the containing window. Activity controls o ActivityInfo adds new constants for managing Activity orientation: SCREEN_ORIENTATION_FULL_SENSOR,SCREEN_ORIENTATION_REVERSE_LANDSCAP E, SCREEN_ORIENTATION_REVERSE_PORTRAIT,SCREEN_ORIENTATION_SENSOR_LANDSCAPE, and SCREEN_ORIENTATION_SENSOR_PORTRAIT. o New constant IMPORTANCE_PERCEPTIBLE for the importance field inActivityManager.RunningAppProcessInfo. The value indicates that a specific process is running something that is considered to be actively perceptible to the user. An example would be an application performing background music playback. o The Activity.setPersistent(boolean) method to mark an Activity as persistent is now deprecated and the implementation is a no-op. Notification text and icon styles o New TextAppearance.StatusBar.EventContent,TextAppearance.StatusBar.EventContent.Title, TextAppearance.St atusBar.Icon, andTextAppearance.StatusBar.Title for managing notification style. WebView o New setUseWebViewBackgroundForOverscrollBackground() method lets a WebView specify whether to use its own background for the overscroll background.

Extra Large Screens The platform now supports extra large screen sizes, such as those that might be found on tablet devices. Developers can indicate that their applications are designed to support extra large screen sizes by adding a element to their manifest files. Applications can use a new resource qualifier,xlarge, to tag resources that are specific to extra large screens. For details on how to support extra large and other screen sizes, see Supporting Multiple Screens. Graphics

Adds remaining OpenGL ES 2.0 methods glDrawElements() and glVertexAttribPointer() in theandroid.opengl.GLES20 class. Adds support for YV12 pixel format, a planar 4:2:0 YCrCb format.

Content Providers

New AlarmClock provider class for setting an alarm or handling an alarm. The provider contains a ACTION_SET_ALARMIntent action and extras that can be used to start an Activity to set a new alarm in an alarm clock application. Applications that wish to receive the SET_ALARM Intent should create an activity that requires the the SET_ALARM permission. Applications that wish to create a new alarm should use Context.startActivity(), so that the user has the option of choosing which alarm clock application to use. MediaStore supports a new Intent action, PLAY_FROM_SEARCH, that lets an application search for music media and automatically play content from the result when possible. For example, an application could fire this Intent as the result of a voice recognition command to listen to music. MediaStore also adds a new MEDIA_IGNORE_FILENAME flag that tells the media scanner to ignore media in the containing directory and its subdirectories. Developers can use this to avoid having graphics appear in the Gallery and likewise prevent application sounds and music from showing up in the Music app. The Settings provider adds the new Activity actions APPLICATION_DETAILS_SETTINGS andMANAGE_ALL_APPLICATIONS_SETTINGS, which let an application show the details screen for a specific application or show the Manage Applications screen. The ContactsContract provider adds the ContactsContract.CommonDataKinds.SipAddress data kind, for storing a contact's SIP (Internet telephony) address.

Location

The LocationManager now tracks application requests that result in wake locks or wifi locks according toWorkSource, a system-managed class that identifies the application.

The LocationManager keeps track of all clients requesting periodic updates, and tells its providers about them as aWorkSource parameter, when setting their minimum update times. The network location provider uses WorkSource to track the wake and wifi locks initiated by an application and adds it to the application's battery usage reported in Manage Applications.

The LocationManager adds several new methods that let an Activity register to receive periodic or one-time location updates based on specified criteria (see below). A new Criteria class lets an application specify a set of criteria for selecting a location provider. For example, providers may be ordered according to accuracy, power usage, ability to report altitude, speed, and bearing, and monetary cost.

Storage

Android 2.3 adds a new StorageManager that supports OBB (Opaque Binary Blob) files. Although platform support for OBB is available in Android 2.3, development tools for creating and managing OBB files will not be availble until early 2011.

The Android 2.3 platform adds official support for devices that do not include SD cards (although it provides virtual SD Card partition, when no physical SD card is available). A convenience method, isExternalStorageRemovable(), lets applications determine whether a physical SD card is present.

Package Manager

New constants for declaring hardware and software features. See the list in the New Feature Constants section, below. PackageInfo adds new firstInstallTime and lastUpdateTime fields that store the time of the package installation and last update. New getProviderInfo() method for retrieving all of the information known about a particular content provider class.

Telephony

The TelephonyManager adds the constant NETWORK_TYPE_EVDO_B for specifying the CDMA EVDO Rev B network type. New getPsc() method returns the primary scrambling code of the serving cell on a UMTS network.

Native access to Activity lifecycle, windows Android 2.3 exposes a broad set of APIs to applications that use native code. Framework classes of interest to such applications include:

NativeActivity is a new type of Activity class, whose lifecycle callbacks are implemented directly in native code. ANativeActivity and its underlying native code run in the system just as do other Activities specifically they run in the Android application's system process and execute on the application's main UI thread, and they receive the same lifecycle callbacks as do other Activities. New InputQueue class and callback interface lets native code manage event queueing. New SurfaceHolder.Callback2 interface lets native code manage a SurfaceHolder. New takeInputQueue and takeSurface() methods in Window let native code manage events and surfaces.

Dalvik Runtime

dalvik.system removes several classes that were previously deprecated. Dalvik core libraries: o New collections: ArrayDeque, NavigableMap, ConcurrentSkipListMap, LinkedBlockingDeque o New Arrays utilities: binarySearch(), copyOf(), copyOfRange(), and others. o CookieManager for HttpURLConnection. o More complete network APIs: InterfaceAddress, NetworkInterface and IDN o File read and write controls o String.isEmpty() o Normalizer and Normalizer.Form o Improved javax.net.ssl server sockets.

New manifest elements and attributes

New xlargeScreens attribute for element, to indicate whether the application supports extra large screen form-factors. For details, see Supporting Multiple Screens. New values for android:screenOrientation attribute of element: o "reverseLandscape" The Activity would like to have the screen in landscape orientation, turned in the opposite direction from normal landscape. o "reversePortrait" The Activity would like to have the screen in portrait orientation, turned in the opposite direction from normal portrait. o "sensorLandscape" The Activity would like to have the screen in landscape orientation, but can use the sensor to change which direction the screen is facing. o "sensorPortrait" The Activity would like to have the screen in portrait orientation, but can use the sensor to change which direction the screen is facing. o "fullSensor" Orientation is determined by a physical orientation sensor: the display will rotate based on how the user moves the device. This allows any of the 4 possible rotations, regardless of what the device will normally do (for example some devices won't normally use 180 degree rotation).

New Permissions

com.android.permission.SET_ALARM Allows an application to broadcast an Intent to set an alarm for the user. An Activity that handles the SET_ALARM Intent action should require this permission. android.permission.USE_SIP Allows an application to use the SIP API to make or receive internet calls. android.permission.NFC Allows an application to use the NFC API to read NFC tags.

New Feature Constants The platform adds several new hardware features that developers can declare in their application manifests as being required by their applications. This lets developers control how their application is filtered, when published on Android Market.

android.hardware.audio.low_latency The application uses a low-latency audio pipeline on the device and is sensitive to delays or lag in sound input or output. android.hardware.camera.front The application uses a front-facing camera on the device. android.hardware.nfc The application uses NFC radio features in the device. android.hardware.sensor.barometer The application uses the device's barometer. android.hardware.sensor.gyroscope The application uses the device's gyroscope sensor. android.software.sip The application uses the SIP API on the device. android.software.sip.voip The application uses a SIP-based VoIP service on the device. android.hardware.touchscreen.multitouch.jazzhand The application uses advanced multipoint multitouch capabilities on the device screen, for tracking five or more points fully independently.

.

API Level The Android 2.3 platform delivers an updated version of the framework API. The Android 2.3 API is assigned an integer identifier 9 that is stored in the system itself. This identifier, called the "API Level", allows the system to correctly determine whether an application is compatible with the system, prior to installing the application. To use APIs introduced in Android 2.3 in your application, you need compile the application against the Android library that is provided in the Android 2.3 SDK platform. Depending on your needs, you might also need to add anandroid:minSdkVersion="9" attribute to the element in the application's manifest. If your application is designed to run only on Android 2.3 and higher, declaring the attribute prevents the application from being installed on earlier versions of the platform.

Built-in Applications The system image included in the downloadable platform provides these built-in applications:

Browser Calculator Camera Clock Contacts Cusom Locale Dev Tools Downloads Email

Gallery IMEs for Japanese, Chinese, and Latin text input Messaging Music Phone Search Settings Spare Parts (developer app) Speech Recorder

Emulator Skins The downloadable platform includes a set of emulator skins that you can use for modeling your application in different screen sizes and resolutions. The emulator skins are:

QVGA (240x320, low density, small screen) WQVGA400 (240x400, low density, normal screen) WQVGA432 (240x432, low density, normal screen) HVGA (320x480, medium density, normal screen) WVGA800 (480x800, high density, normal screen) WVGA854 (480x854 high density, normal screen)

Android 2.3 PlatformAPI Level: 9 For developers, the Android 2.3 platform is available as a downloadable component for the Android SDK. The downloadable platform includes an Android library and system image, as well as a set of emulator skins and more. The downloadable platform includes no external libraries. To get started developing or testing against Android 2.3, use the Android SDK Manager to download the platform into your SDK. For more information, see Adding SDK Components. If you are new to Android, download the SDK Starter Package first. For a high-level introduction to Android 2.3, see the Platform Highlights.

Revisions The sections below provide notes about successive releases of the Android 2.3 platform component for the Android SDK, as denoted by revision number. To determine what revision(s) of the Android 2.3 platforms are installed in your SDK environment, refer to the "Installed Packages" listing in the Android SDK and AVD Manager. Android 2.3, Revision 1 (December 2010) Dependencies: Requires SDK Tools r8 or higher.

API Overview The sections below provide a technical overview of what's new for developers in 2.3, including new features and changes in the framework API since the previous version. SIP-based VoIP The platform now includes a SIP protocol stack and framework API that lets developers build internet telephony applications. Using the API, applications can offer voice calling features without having to manage sessions, transport-level communication, or audio these are handled transparently by the platform's SIP API and services. The SIP API is available in the android.net.sip package. The key class is SipManager, which applications use to set up and manage SIP profiles, then initiate audio calls and receive audio calls. Once an audio call is established, applications can mute calls, turn on speaker mode, send DTMF tones, and more. Applications can also use the SipManager to create generic SIP connections. The platforms underlying SIP stack and services are available on devices at the discretion of the manufacturer and associated carrier. For this reason, applications should use the isApiSupported() method to check whether SIP support is available, before exposing calling functionality to users. To use the SIP API, applications must request permission from the user by declaring and in their manifest files. Additionally, developers can request filtering on Android Market, such that their applications are not discoverable to users whose devices do not include the platforms SIP stack and services. To request filtering, add and to the application manifest. To look at a sample application that uses the SIP API, see SIP Demo. Near Field Communications (NFC) Android 2.3 includes an NFC stack and framework API that lets developers read NDEF tags that are discovered as a user touches an NFC-enabled device to tag elements embedded in stickers, smart posters, and even other devices. The platform provides the underlying NFC services that work with the device hardware to discover tags when they come into range. On discovering a tag, the platform notifies applications by broadcasting an Intent, appending the tag's NDEF messages to the Intent as extras. Applications can create Intent filters to recognize and handle targeted tags and messages. For example, after receiving a tag by Intent, applications extract the NDEF messages, store them, alert the user, or handle them in other ways. The NFC API is available in the android.nfc package. The key classes are:

NfcAdapter, which represents the NFC hardware on the device. NdefMessage, which represents an NDEF data message, the standard format in which "records" carrying data are transmitted between devices and tags. Applications can receive these messages from ACTION_TAG_DISCOVEREDIntents. NdefRecord, delivered in an NdefMessage, which describes the type of data being shared and carries the data itself.

NFC communication relies on wireless technology in the device hardware, so support for the platform's NFC features on specific devices is determined by their manufacturers. To determine the NFC support on the current device, applications can call isEnabled() to query the NfcAdapter. The NFC API is always present, however, regardless of underlying hardware support. To use the NFC API, applications must request permission from the user by declaring in their manifest files. Additionally, developers can request filtering on Android Market, such that their applications are not discoverable to users whose devices do not support NFC. To request filtering, add to the application's manifest. To look at a sample application that uses the NFC API, see NFCDemo. Gyroscope and other sensors

Android 2.3 adds platform and API support for several new sensor reading types gyroscope, rotation vector, linear acceleration, gravity, and barometer. Developers can use the new sensor readings to create applications that respond quickly and smoothly to precise changes in device position and motion. The Sensor API reports gyroscope and other sensor changes to interested applications, whether they are running on the application framework or in native code. Note that the specific set of hardware sensors available on any given device varies at the discretion of the device manufacturer. Developers can request filtering in Android Market, such that their applications are not discoverable to users whose devices do not offer a gyroscope sensor. To do so, add to the application manifest. Multiple cameras support Applications can now make use of any cameras that are available on a device, for either photo or video capture. The Cameralets applications query for the number of cameras available and the unique characteristics of each.

New Camera.CameraInfo class stores a camera's positional characteristics (orientation, front-facing or back-facing). New getNumberOfCameras() and getCameraInfo() methods in the Camera class let applications query for the cameras available and open the camera that they need. New get() method lets applications retrieve a CamcorderProfile for a specific camera. New getJpegEncodingQualityParameter() lets applications obtain the still-image capture quality level for a specific camera.

To look at sample code for accessing a front-facing camera, see CameraPreview.java in the ApiDemos sample application. The Camera API also adds:

New parameters for cameras, including focus distance, focus mode, and preview fps maximum/minimum. NewgetFocusDistances(), getPreviewFpsRange(), and getSupportedPreviewFpsRange() for getting camera parameters, as well as setPreviewFpsRange() for setting preview framerate.

Mixable audio effects The platform's media framework adds support for new per-track or global audio effects, including bass boost, headphone virtualization, equalization, and reverb.

New android.media.audiofx package provides the API to access audio effects. New AudioEffect is the base class for controlling audio effects provided by the Android audio framework. New audio session ID that lets an application associate a set of audio effects with an instance of AudioTrack orMediaPlayer. New AudioTrack class constructor that lets you create an AudioTrack with a specific session ID. NewattachAuxEffect(), getAudioSessionId(), and setAuxEffectSendLevel() methods. New attachAuxEffect(), getAudioSessionId(), setAudioSessionId(int), andsetAuxEffectSendLevel() methods and supporting types.

To look at sample code for audio effects, see AudioFxDemo.java in the ApiDemos sample application. The media framework also adds:

New support for altitude tag in EXIF metadata for JPEG files. New method getAltitude() method to retrieve the value of the EXIF altitude tag. New setOrientationHint() method lets an application tell MediaRecorder of the orientation during video capture.

Download manager

The platform includes a new DownloadManager system service that handles long-running HTTP downloads. Applications can request that a URI be downloaded to a particular destination file. The DownloadManager will conduct the download in the background, taking care of HTTP interactions and retrying downloads after failures or across connectivity changes and system reboots.

Applications can obtain an instance of the DownloadManager class by calling getSystemService(String) and passing DOWNLOAD_SERVICE. Applications that request downloads through this API should register a broadcast receiver for ACTION_NOTIFICATION_CLICKED, to appropriately handle when the user clicks on a running download in a notification or from the Downloads UI. The DownloadManager.Request class lets an application provide all the information necessary to request a new download, such as request URI and download destination. A request URI is the only required parameter. Note that the default download destination is a shared volume where the system can delete your file if it needs to reclaim space for system use. For persistent storage of a download, specify a download destination on external storage (seesetDestinationUri(Uri)). The DownloadManager.Query class provides methods that let an application query for and filter active downloads.

StrictMode To help developers monitor and improve the performance of their applications, the platform offers a new system facility calledStrictMode. When implemented in an application, StrictMode catches and notifies the developer of accidental disk or network activity that could degrade application performance, such as activity taking place on the application's main thread (where UI operations are received and animations are also taking place). Developers can evaluate the network and disk usages issues raised in StrictMode and correct them if needed, keeping the main thread more responsive and preventing ANR dialogs from being shown to users.

StrictMode is the core class and is the main integration point with the system and VM. The class provides convenience methods for managing the thread and VM policies that apply to the instance. StrictMode.ThreadPolicy and StrictMode.VmPolicy hold the policies that you define and apply to thread and VM instances.

For more information about how to use StrictMode to optimize your application, see the class documentation and sample code at android.os.StrictMode. UI Framework

Support for overscroll o New support for overscroll in Views and Widgets. In Views, applications can enable/disable overscroll for a given view, set the overscoll mode, control the overscroll distance, and handle the results of overscrolling. o In Widgets, applications can control overscroll characteristics such as animation, springback, and overscroll distance. For more information, see android.view.View and android.widget.OverScroller. o ViewConfiguration also provides methods getScaledOverflingDistance() andgetScaledOverscrollDistance(). o New overScrollMode, overScrollFooter, and overScrollHeader attributes for elements, for controlling overscroll behavior. Support for touch filtering o New support for touch filtering, which lets an application improve the security of Views that provide access to sensitive functionality. For example, touch filtering is appropriate to ensure the security of user actions such as granting a permission request, making a purchase, or clicking on an advertisement. For details, see the View class documentation. o New filterTouchesWhenObscured attribute for view elements, which declares whether to filter touches when the view's window is obscured by another visible window. When set to "true", the view will not receive touches whenever a toast, dialog or other window appears above the view's window. Refer to View security documentation for details.

To look at sample code for touch filtering, see SecureView.java in the ApiDemos sample application.

Improved event management

New base class for input events, InputEvent. The class provides methods that let applications determine the meaning of the event, such as by querying for the InputDevice from which the event orginated. The KeyEvent andMotionEvent are subclasses of InputEvent. o New base class for input devices, InputDevice. The class stores information about the capabilities of a particular input device and provides methods that let applications determine how to interpret events from an input device. Improved motion events o The MotionEvent API is extended to include "pointer ID" information, which lets applications to keep track of individual fingers as they move up and down. The class adds a variety of methods that let an application work efficiently with motion events. o The input system now has logic to generate motion events with the new pointer ID information, synthesizing identifiers as new pointers are down. The system tracks multiple pointer IDs separately during a motion event, and ensures proper continuity of pointers by evaluating at the distance between the last and next set of pointers. Text selection controls o A new setComposingRegion method lets an application mark a region of text as composing text, maintaining the current styling. A getSelectedText method returns the selected text to the application. The methods are available in BaseInputConnection, InputConnection, and InputConnectionWrapper. o New textSelectHandle, textSelectHandleLeft, textSelectHandleRight, andtextSelectHandleWindowStyle attributes for , for referencing drawables that will be used to display text-selection anchors and the style for the containing window. Activity controls o ActivityInfo adds new constants for managing Activity orientation: SCREEN_ORIENTATION_FULL_SENSOR,SCREEN_ORIENTATION_REVERSE_LANDSCAP E, SCREEN_ORIENTATION_REVERSE_PORTRAIT,SCREEN_ORIENTATION_SENSOR_LANDSCAPE, and SCREEN_ORIENTATION_SENSOR_PORTRAIT. o New constant IMPORTANCE_PERCEPTIBLE for the importance field inActivityManager.RunningAppProcessInfo. The value indicates that a specific process is running something that is considered to be actively perceptible to the user. An example would be an application performing background music playback. o The Activity.setPersistent(boolean) method to mark an Activity as persistent is now deprecated and the implementation is a no-op. Notification text and icon styles o New TextAppearance.StatusBar.EventContent,TextAppearance.StatusBar.EventContent.Title, TextAppearance.St atusBar.Icon, andTextAppearance.StatusBar.Title for managing notification style. WebView o New setUseWebViewBackgroundForOverscrollBackground() method lets a WebView specify whether to use its own background for the overscroll background.

o

Extra Large Screens The platform now supports extra large screen sizes, such as those that might be found on tablet devices. Developers can indicate that their applications are designed to support extra large screen sizes by adding a element to their manifest files. Applications can use a new resource qualifier,xlarge, to tag resources that are specific to extra large screens. For details on how to support extra large and other screen sizes, see Supporting Multiple Screens. Graphics

Adds remaining OpenGL ES 2.0 methods glDrawElements() and glVertexAttribPointer() in theandroid.opengl.GLES20 class. Adds support for YV12 pixel format, a planar 4:2:0 YCrCb format.

Content Providers

New AlarmClock provider class for setting an alarm or handling an alarm. The provider contains a ACTION_SET_ALARMIntent action and extras that can be used to start an Activity to set a new alarm in an alarm clock application. Applications that wish to receive the SET_ALARM Intent should create an activity that requires the the

SET_ALARM permission. Applications that wish to create a new alarm should use Context.startActivity(), so that the user has the option of choosing which alarm clock application to use. MediaStore supports a new Intent action, PLAY_FROM_SEARCH, that lets an application search for music media and automatically play content from the result when possible. For example, an application could fire this Intent as the result of a voice recognition command to listen to music. MediaStore also adds a new MEDIA_IGNORE_FILENAME flag that tells the media scanner to ignore media in the containing directory and its subdirectories. Developers can use this to avoid having graphics appear in the Gallery and likewise prevent application sounds and music from showing up in the Music app. The Settings provider adds the new Activity actions APPLICATION_DETAILS_SETTINGS andMANAGE_ALL_APPLICATIONS_SETTINGS, which let an application show the details screen for a specific application or show the Manage Applications screen. The ContactsContract provider adds the ContactsContract.CommonDataKinds.SipAddress data kind, for storing a contact's SIP (Internet telephony) address.

Location

The LocationManager now tracks application requests that result in wake locks or wifi locks according toWorkSource, a system-managed class that identifies the application.

The LocationManager keeps track of all clients requesting periodic updates, and tells its providers about them as aWorkSource parameter, when setting their minimum update times. The network location provider uses WorkSource to track the wake and wifi locks initiated by an application and adds it to the application's battery usage reported in Manage Applications.

The LocationManager adds several new methods that let an Activity register to receive periodic or one-time location updates based on specified criteria (see below). A new Criteria class lets an application specify a set of criteria for selecting a location provider. For example, providers may be ordered according to accuracy, power usage, ability to report altitude, speed, and bearing, and monetary cost.

Storage

Android 2.3 adds a new StorageManager that supports OBB (Opaque Binary Blob) files. Although platform support for OBB is available in Android 2.3, development tools for creating and managing OBB files will not be availble until early 2011. The Android 2.3 platform adds official support for devices that do not include SD cards (although it provides virtual SD Card partition, when no physical SD card is available). A convenience method, isExternalStorageRemovable(), lets applications determine whether a physical SD card is present.

Package Manager

New constants for declaring hardware and software features. See the list in the New Feature Constants section, below. PackageInfo adds new firstInstallTime and lastUpdateTime fields that store the time of the package installation and last update. New getProviderInfo() method for retrieving all of the information known about a particular content provider class.

Telephony

The TelephonyManager adds the constant NETWORK_TYPE_EVDO_B for specifying the CDMA EVDO Rev B network type. New getPsc() method returns the primary scrambling code of the serving cell on a UMTS network.

Native access to Activity lifecycle, windows Android 2.3 exposes a broad set of APIs to applications that use native code. Framework classes of interest to such applications include:

NativeActivity is a new type of Activity class, whose lifecycle callbacks are implemented directly in native code. ANativeActivity and its underlying native code run in the system just as do other Activities specifically they run in the Android application's system process and execute on the application's main UI thread, and they receive the same lifecycle callbacks as do other Activities. New InputQueue class and callback interface lets native code manage event queueing. New SurfaceHolder.Callback2 interface lets native code manage a SurfaceHolder. New takeInputQueue and takeSurface() methods in Window let native code manage events and surfaces.

For full information on working with native code or to download the NDK, see the Android NDK page. Dalvik Runtime

dalvik.system removes several classes that were previously deprecated. Dalvik core libraries: o New collections: ArrayDeque, NavigableMap, ConcurrentSkipListMap, LinkedBlockingDeque o New Arrays utilities: binarySearch(), copyOf(), copyOfRange(), and others. o CookieManager for HttpURLConnection. o More complete network APIs: InterfaceAddress, NetworkInterface and IDN o File read and write controls o String.isEmpty() o Normalizer and Normalizer.Form o Improved javax.net.ssl server sockets.

New manifest elements and attributes

New xlargeScreens attribute for element, to indicate whether the application supports extra large screen form-factors. For details, see Supporting Multiple Screens. New values for android:screenOrientation attribute of element: o "reverseLandscape" The Activity would like to have the screen in landscape orientation, turned in the opposite direction from normal landscape. o "reversePortrait" The Activity would like to have the screen in portrait orientation, turned in the opposite direction from normal portrait. o "sensorLandscape" The Activity would like to have the screen in landscape orientation, but can use the sensor to change which direction the screen is facing. o "sensorPortrait" The Activity would like to have the screen in portrait orientation, but can use the sensor to change which direction the screen is facing. o "fullSensor" Orientation is determined by a physical orientation sensor: the display will rotate based on how the user moves the device. This allows any of the 4 possible rotations, regardless of what the device will normally do (for example some devices won't normally use 180 degree rotation).

New Permissions

com.android.permission.SET_ALARM Allows an application to broadcast an Intent to set an alarm for the user. An Activity that handles the SET_ALARM Intent action should require this permission. android.permission.USE_SIP Allows an application to use the SIP API to make or receive internet calls. android.permission.NFC Allows an application to use the NFC API to read NFC tags.

New Feature Constants The platform adds several new hardware features that developers can declare in their application manifests as being required by their applications. This lets developers control how their application is filtered, when published on Android Market.

android.hardware.audio.low_latency The application uses a low-latency audio pipeline on the device and is sensitive to delays or lag in sound input or output. android.hardware.camera.front The application uses a front-facing camera on the device. android.hardware.nfc The application uses NFC radio features in the device. android.hardware.sensor.barometer The application uses the device's barometer. android.hardware.sensor.gyroscope The application uses the device's gyroscope sensor. android.software.sip The application uses the SIP API on the device. android.software.sip.voip The application uses a SIP-based VoIP service on the device. android.hardware.touchscreen.multitouch.jazzhand The application uses advanced multipoint multitouch capabilities on the device screen, for tracking five or more points fully independently.

API Level The Android 2.3 platform delivers an updated version of the framework API. The Android 2.3 API is assigned an integer identifier 9 that is stored in the system itself. This identifier, called the "API Level", allows the system to correctly determine whether an application is compatible with the system, prior to installing the application. To use APIs introduced in Android 2.3 in your application, you need compile the application against the Android library that is provided in the Android 2.3 SDK platform. Depending on your needs, you might also need to add anandroid:minSdkVersion="9" attribute to the element in the application's manifest. If your application is designed to run only on Android 2.3 and higher, declaring the attribute prevents the application from being installed on earlier versions of the platform.

Built-in Applications The system image included in the downloadable platform provides these built-in applications:

Browser Calculator Camera Clock Contacts Cusom Locale Dev Tools

Gallery IMEs for Japanese, Chinese, and Latin text input Messaging Music Phone Search Settings

Downloads Email

Spare Parts (developer app) Speech Recorder

Android 2.3.3 PlatformAPI Level: 10 Android 2.3.3 is a small feature release that adds several improvements and APIs to the Android 2.3 platform. For developers, the Android 2.3.3 platform is available as a downloadable component for the Android SDK. The downloadable platform includes an Android library and system image, as well as a set of emulator skins and more. The downloadable platform includes no external libraries. To get started developing or testing against Android 2.3.3, use the Android SDK Manager to download the platform into your SDK. For more information, see Adding SDK Components. If you are new to Android, download the SDK Starter Package first. For a high-level introduction to Android 2.3, see the Platform Highlights.

Revisions The sections below provide notes about successive releases of the Android 2.3.3 platform component for the Android SDK, as denoted by revision number. To determine what revision(s) of the Android 2.3.3 platforms are installed in your SDK environment, refer to the "Installed Packages" listing in the Android SDK and AVD Manager. Dependencies: Requires SDK Tools r12 or higher. Notes: Improvements to the platform's rendering library to support the visual layout editor in the ADT Eclipse plugin. This revision allows for more drawing features in ADT and fixes several bugs in the previous rendering library. It also unlocks several editor features that were added in ADT 12.

API Overview The sections below provide a technical overview of what's new for developers in 2.3.3, including new features and changes in the framework API since the previous version. Near Field Communications (NFC) Android 2.3.3 provides improved and extended support for NFC, to allow applications to interact with more types of tags in new ways. A new, comprehensive set of APIs give applications read and write access to a wider range of standard tag technologies, including:

NFC-A (ISO 14443-3A) NFC-B (ISO 14443-3B) NFC-F (JIS 6319-4) NFC-V (ISO 15693) ISO-DEP (ISO 14443-4) MIFARE Classic MIFARE Ultralight NFC Forum NDEF tags

The platform also provides a limited peer-to-peer communication protocol and API. Foreground Activities can use the API to register an NDEF message that will get pushed to other NFC devices when they connect.

Advanced tag dispatching now gives applications more control over how and when they are launched, when an NFC tag is discovered. Previously, the platform used a single-step intent dispatch to notify interested applications that a tag was discovered. The platform now uses a four-step process that enables the foreground application to take control of a tag event before it is passed to any other applications (android.nfc.NfcAdapter.enableForegroundDispatch()). The new dispatch process also lets apps listen for specific tag content and tag technologies, based on two new intent actions android.nfc.action.NDEF_DISCOVERED and android.nfc.action.TECH_DISCOVERED. The NFC API is available in the android.nfc and android.nfc.tech packages. The key classes are:

NfcAdapter, which represents the NFC hardware on the device. NdefMessage, which represents an NDEF data message, the standard format in which "records" carrying data are transmitted between devices and tags. An NDEF message certain many NDEF records of different types. Applications can receive these messages from NDEF_DISCOVERED, TECH_DISCOVERED, or TAG_DISCOVERED Intents. NdefRecord, delivered in an NdefMessage, which describes the type of data being shared and carries the data itself. Tag, which represents a tag scanned by the device. Multiple types of tags are supported, based on the underlying tag technology. TagTechnology, an interface that gives applications access to tag properties and I/O operations based on the technologies present in the tag. For a full list of tag technologies supported in Android 2.3.3, see android.nfc.tech.

NFC communication relies on wireless technology in the device hardware, and is not present in all Android devices. Android devices that do not support NFC will return a null object when getDefaultAdapter(Context) is called, andcontext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC) will return false. The NFC API is always present, however, regardless of underlying hardware support. To use the NFC API, applications must request permission from the user by declaring in their manifest files. Additionally, developers can request filtering on Android Market, such that their applications are not discoverable to users whose devices do not support NFC. To request filtering, add to the application's manifest. To look at sample code for NFC, see NFCDemo app, filtering by tag technology, using foreground dispatch, andforeground NDEF push (P2P). Bluetooth Android 2.3.3 adds platform and API support for Bluetooth nonsecure socket connections. This lets applications communicate with simple devices that may not offer a UI for authentication. SeecreateInsecureRfcommSocketToServiceRecord(java.util.UUID) andlistenUsingInsecureRfcommWithServiceRecord(java.lang.String, java.util.UUID) for more information. Graphics

A new BitmapRegionDecoder class lets applications decode a rectangle region from an image. The API is particularly useful when an original image is large and and the application only need parts of the image. A new inPreferQualityOverSpeed field in BitmapFactory.Options allows applications to use a more accurate but slightly slower IDCT method in JPEG decode. This in turn improves the quality of the reconstructed image.

Media framework

A new MediaMetadataRetriever class provides a unified interface for retrieving frame and metadata from an input media file. MediaRecorder.AudioEncoder and MediaRecorder.OutputFormat include new fields for specifying AMR Wideband and AAC formats.

Speech recognition

The speech-recognition API includes new constants to let you manage voice search results in new ways. Although the new constants are not needed for normal use of speech recognition, you could use them to offer a different view of voice search results in your application. For information, see RecognizerResultsIntent.

API Level The Android 2.3.3 platform delivers an updated version of the framework API. The Android 2.3.3 API is assigned an integer identifier 10 that is stored in the system itself. This identifier, called the "API Level", allows the system to correctly determine whether an application is compatible with the system, prior to installing the application. To use APIs introduced in Android 2.3.3 in your application, you need compile the application against the Android library that is provided in the Android 2.3.3 SDK platform. Depending on your needs, you might also need to add anandroid:minSdkVersion="10" attribute to the element in the application's manifest. If your application is designed to run only on Android 2.3 and higher, declaring the attribute prevents the application from being installed on earlier versions of the platform.

Built-in Applications The system image included in the downloadable platform provides these built-in applications:

Browser Calculator Camera Clock Contacts Cusom Locale Dev Tools Downloads Email

Gallery IMEs for Japanese, Chinese, and Latin text input Messaging Music Phone Search Settings Spare Parts (developer app) Speech Recorder

Android 2.3.3 PlatformAPI Level: 10 Android 2.3.3 is a small feature release that adds several improvements and APIs to the Android 2.3 platform. For developers, the Android 2.3.3 platform is available as a downloadable component for the Android SDK. The downloadable platform includes an Android library and system image, as well as a set of emulator skins and more. The downloadable platform includes no external libraries. To get started developing or testing against Android 2.3.3, use the Android SDK Manager to download the platform into your SDK. For more information, see Adding SDK Components. If you are new to Android, download the SDK Starter Package first. For a high-level introduction to Android 2.3, see the Platform Highlights.

Revisions The sections below provide notes about successive releases of the Android 2.3.3 platform component for the Android SDK, as denoted by revision number. To determine what revision(s) of the Android 2.3.3 platforms are installed in your SDK environment, refer to the "Installed Packages" listing in the Android SDK and AVD

Dependencies:

Requires SDK Tools r12 or higher.

API Overview The sections below provide a technical overview of what's new for developers in 2.3.3, including new features and changes in the framework API since the previous version. Near Field Communications (NFC) Android 2.3.3 provides improved and extended support for NFC, to allow applications to interact with more types of tags in new ways. A new, comprehensive set of APIs give applications read and write access to a wider range of standard tag technologies, including:

NFC-A (ISO 14443-3A) NFC-B (ISO 14443-3B) NFC-F (JIS 6319-4) NFC-V (ISO 15693) ISO-DEP (ISO 14443-4) MIFARE Classic MIFARE Ultralight NFC Forum NDEF tags

The platform also provides a limited peer-to-peer communication protocol and API. Foreground Activities can use the API to register an NDEF message that will get pushed to other NFC devices when they connect. Advanced tag dispatching now gives applications more control over how and when they are launched, when an NFC tag is discovered. Previously, the platform used a single-step intent dispatch to notify interested applications that a tag was discovered. The platform now uses a four-step process that enables the foreground application to take control of a tag event before it is passed to any other applications (android.nfc.NfcAdapter.enableForegroundDispatch()). The new dispatch process