blob: 57fe1ebc35c98a79d0d59d33964c72ff2003d9aa [file] [log] [blame]
Dirk Doughertyb7c7f152011-03-25 11:54:46 -07001page.title=Android 3.1 Platform
2sdk.platform.version=3.1
3sdk.platform.apiLevel=12
4@jd:body
5
6<div id="qv-wrapper">
7<div id="qv">
8
9<h2>In this document</h2>
10<ol>
11 <li><a href="#relnotes">Revisions</a></li>
12 <li><a href="#api">API Overview</a></li>
13 <li><a href="#api-level">API Level</a></li>
14 <li><a href="#apps">Built-in Applications</a></li>
15 <li><a href="#locs">Locales</a></li>
16 <li><a href="#skins">Emulator Skins</a></li>
17</ol>
18
19<h2>Reference</h2>
20<ol>
21<li><a
22href="{@docRoot}sdk/api_diff/11/changes.html">API
23Differences Report &raquo;</a> </li>
24</ol>
25
26<h2>See Also</h2>
27<ol>
28 <li><a href="{@docRoot}guide/practices/optimizing-for-3.0.html">Optimizing
29Apps for Android 3.0</a></li>
30</ol>
31
32</div>
33</div>
34
35
36<p><em>API Level:</em>&nbsp;<strong>{@sdkPlatformApiLevel}</strong></p>
37
38<p>For developers, the Android {@sdkPlatformVersion} platform is available as a
39downloadable component for the Android SDK. The downloadable platform includes
40an Android library and system image, as well as a set of emulator skins and
41more. The downloadable platform includes no external libraries.</p>
42
43<p>To get started developing or testing against Android {@sdkPlatformVersion},
44use the Android SDK Manager to download the platform into your SDK. For more
45information, see <a href="{@docRoot}sdk/adding-components.html">Adding SDK
46Components</a>. If you are new to Android, <a
47href="{@docRoot}sdk/index.html">download the SDK Starter Package</a> first.</p>
48
49<p>For a high-level introduction to Android {@sdkPlatformVersion}, see the <a
50href="{@docRoot}sdk/android-{@sdkPlatformVersion}-highlights.html">Platform
51Highlights</a>.</p>
52
53<p class="note"><strong>Reminder:</strong> If you've already published an
54Android application, please test and optimize your application on Android 3.0
55and Android 3.1 as soon as possible. You should do so to be sure your
56application provides the best experience possible on the latest Android-powered
57devices. For information about what you can do, read <a
58href="{@docRoot}guide/practices/optimizing-for-3.0.html">Optimizing Apps for
59Android 3.0</a>.</p>
60
61
62<h2 id="relnotes">Revisions</h2>
63
64<p>To determine what revision of the Android {@sdkPlatformVersion} platform you
65have installed, refer to the "Installed Packages" listing in the Android SDK and
66AVD Manager.</p>
67
68
69<div class="toggle-content opened" style="padding-left:1em;">
70
71 <p><a href="#" onclick="return toggleContent(this)">
72 <img src="{@docRoot}assets/images/triangle-opened.png"
73class="toggle-content-img" alt="" />
74 Android {@sdkPlatformVersion}, Revision 1</a> <em>(May 2011)</em>
75 </a></p>
76
77 <div class="toggle-content-toggleme" style="padding-left:2em;">
78
79<dl>
80
81<dt>Dependencies:</dt>
82<dd>
83<p>Requires <a href="{@docRoot}sdk/tools-notes.html">SDK Tools r11</a> or
84higher.</p>
85</dd>
86
87</dl>
88
89 </div>
90</div>
91
92
93<h2 id="#api" style="margin-top:1.5em;">API Overview</h2>
94
95<p>The sections below provide a technical overview of what's new for developers
96in Android 3.1, including new features and changes in the framework API since
97the previous version.</p>
98
99<h3 id="usb">USB APIs</h3>
100
101<p>Android 3.1 introduces powerful new APIs for
102integrating connected peripherals with applications running on the platform.
103The APIs are based on a USB (Universal Serial Bus) stack and services that are
104built into the platform, including support for both USB host and device
105interactions. Using the APIs, developers can create applications that are able to
106discover, communicate with, and manage a variety of device types connected over
107USB. </p>
108
109<p>The stack and APIs distinguish two basic types of USB hardware, based on
110whether the platform iself is acting as host or the external hardware is acting
111as host: </p>
112
113<ul>
114<li>A <em>USB device</em> is a piece of connected hardware that depends on the
115Android-powered device to serve as host. For example, most input devices, mice,
116and joysticks are USB devices, as are many cameras, hubs, and so on.</li>
117<li>A <em>USB accessory</em> is a piece of connected hardware that has a USB
118host controller, provides power, and is designed to communicate with
119Android-powered devices over USB, A variety of peripherals can connect as
120accessories, from robotics controllers to musical equipment, exercise bicycles,
121and more.</li>
122</ul>
123
124<p>For both types &mdash; USB devices and USB accessories &mdash; the
125platform's USB APIs support discovery by intent broadcast when attached or
126detached, as well as standard interfaces, endpoints, and transfer modes
127(control, bulk, and interrupt).</p>
128
129<p>The USB APIs are available in the package {@link android.hardware.usb}. The
130central class is {@link android.hardware.usb.UsbManager}, which provides
131helper methods for identifying and communicating with
132both USB devices and USB accessories. Applications can acquire an instance of
133{@link android.hardware.usb.UsbManager} and then query for the list of attached
134devices or accessories and then communicate with or manage them.
135{@link android.hardware.usb.UsbManager} also declares intent actions that the
136system broadcasts, to announce when a USB device or accessory is attached or
137detached.</p>
138
139<p>Other classes include:</p>
140
141<ul>
142<li>{@link android.hardware.usb.UsbDevice}, a class representing external
143hardware connected as a USB device (with the Android-powered device acting as
144host).</li>
145<li>{@link android.hardware.usb.UsbAccessory}, representing external hardware
146connected as the USB host (with the Android-powered device acting as a USB
147device).</li>
148<li>{@link android.hardware.usb.UsbInterface} and {@link
149android.hardware.usb.UsbEndpoint}, which provide access to standard USB
150interfaces and endpoints for a device.</li>
151<li>{@link android.hardware.usb.UsbDeviceConnection} and {@link
152android.hardware.usb.UsbRequest}, for sending and receiving data and control
153messages to or from a USB device, sychronously and asynchronously.
154<li>{@link android.hardware.usb.UsbConstants}, which provides constants for
155declaring endpoint types, device classes, and so on.</li>
156</ul>
157
158<p>Note that although the USB stack is built into the platform, actual support
159for USB host and open accessory modes on specific devices is determined by
160their manufacturers. In particular, host mode relies on appropriate USB
161controller hardware in the Android-powered device. </p>
162
163<p>Additionally, developers can request filtering on Android Market, such that
164their applications are not availabe to users whose devices do not provide the
165appropriate USB support. To request filtering, add one or both of the elements
166below to the application manifest, as appropriate: </p>
167
168<ul>
169<li>If the application should only be visible to devices that support USB
170host mode (connection of USB devices), declare this element:
171 <p style="margin-left:1.5em;"><code>&lt;uses-feature
172 android:name="android.hardware.usb.host"
173 android:required="true"&gt;</code></p>
174</li>
175<li>If the application should only be visible to devices that support USB
176accessories (connection of USB hosts), declare this element:
177 <p style="margin-left:1.5em;"><code>&lt;uses-feature
178 android:name="android.hardware.usb.accessory"
179 android:required="true"&gt;</code></p>
180</li>
181</ul>
182
183<p>For complete information about how to develop applications that interact with
184USB accessories, please see the
185<a href="{@docRoot}guide/topics/usb/index.html">developer documentation</a>.</p>
186
187<p class="note">To look at sample applications that use the USB host API, see <a
188href="{@docRoot}resources/samples/USB/AdbTest/index.html">ADB Test</a> and <a
189href="{@docRoot}resources/samples/USB/MissileLauncher/index.html">Missile
190Launcher</a></p>
191
192<h3>MTP/PTP API</h3>
193
194<p>Android 3.1 exposes a new MTP API that lets applications interact directly
195with connected cameras and other PTP devices. The new API makes it easy for an
196application to receive notifications when devices are attached and removed,
197manage files and storage on those devices, and transfer files and metadata to
198and from them. The MTP API implements the PTP (Picture Transfer Protocol) subset
199of the MTP (Media Transfer Protocol) specification.</p>
200
201<p>The MTP API is available in the {@link android.mtp} package and provides
202these classes: </p>
203
204<ul>
205 <li>The {@link android.mtp.MtpDevice} encapsulates an MTP device that is
206connected over the USB host bus. An application can instantiate an object of
207this type and then use its methods to get information about the device and
208objects stored on it, as well as opening the connection and transferring data.
209Some of the methods include:
210 <ul>
211 <li>{@link android.mtp.MtpDevice#getObjectHandles(int, int, int)
212getObjectHandles()} returns a list of handles for all objects on the device that
213match a specified format and parent. To get information about an object, an
214application can pass a handle to {@link android.mtp.MtpDevice#getObjectInfo(int)
215getObjectInfo()}.</li>
216 <li>{@link android.mtp.MtpDevice#importFile(int, java.lang.String)
217importFile()} lets an application copy data for an object to a file in external
218storage. This call may block for an arbitrary amount of time depending on the
219size of the data and speed of the devices, so should be made from a spearate
220thread.</li>
221 <li>{@link
222android.mtp.MtpDevice#open(android.hardware.usb.UsbDeviceConnection) open()}
223lets an application open a connected MTP/PTP device. </li>
224 <li>{@link android.mtp.MtpDevice#getThumbnail(int) getThumbnail()} returns
225the thumbnail of the object as a byte array. </li>
226 </ul>
227 </li>
228 <li>{@link android.mtp.MtpStorageInfo} holds information about about a storage
229unit on an MTP device, corresponding to the StorageInfo Dataset described in
230section 5.2.2 of the MTP specification. Methods in the class let an application
231get a storage unit’s description string, free space, maximum storage capacity,
232storage ID, and volume identifier.</li>
233 <li>{@link android.mtp.MtpDeviceInfo} holds information about an MTP device
234corresponding to the DeviceInfo Dataset described in section 5.1.1 of the MTP
235specification. Methods in the class let applications get a device’s
236manufacturer, model, serial number, and version.</li>
237 <li>{@link android.mtp.MtpObjectInfo} holds information about an object stored
238on an MTP device, corresponding to the ObjectInfo Dataset described in section
2395.3.1 of the MTP specification. Methods in the class let applications get an
240object’s size, data format, association type, creation date, and thumbnail
241information.</li>
242 <li>{@link android.mtp.MtpConstants} provides constants for declaring MTP file
243format codes, association type, and protection status.</li>
244</ul>
245
246<h3 id="motionevents">Support for new input devices and motion events</h3>
247
248<p>Android 3.1 extends the input subsystem to support new input devices and new
249types of motion events, across all views and windows. Developers can build on
250these capabilities to let users interact with their applications using mice,
251trackballs, joysticks, gamepads, and other devices, in addition to keyboards and
252touchscreens. </p>
253
254<p>For handling mouse, scrollwheel, and trackball input, the platform supports
255two new motion event actions:</p>
256<ul>
257<li>{@link android.view.MotionEvent#ACTION_SCROLL}, which describes the pointer
258location at which a non-touch scroll motion, such as from a mouse scroll wheel,
259took place. In the MotionEvent, the value of the {@link
260android.view.MotionEvent#AXIS_HSCROLL} and {@link
261android.view.MotionEvent#AXIS_VSCROLL} axes specify the relative scroll
262movement. </li>
263<li>{@link android.view.MotionEvent#ACTION_HOVER_MOVE}, reports the current
264position of the mouse when no buttons are pressed, as well as any intermediate
265points since the last <code>HOVER_MOVE</code> event. Hover enter and exit
266notifications are not yet supported.</li>
267</ul>
268
269<p>To support joysticks and gamepads, the {@link android.view.InputDevice} class
270includes these new input device sources:</p>
271<ul>
272<li>{@link android.view.InputDevice#SOURCE_CLASS_JOYSTICK} &mdash; the source
273device has joystick axes.</li>
274<li>{@link android.view.InputDevice#SOURCE_CLASS_BUTTON} &mdash; the source
275device has buttons or keys.</li>
276<li>{@link android.view.InputDevice#SOURCE_GAMEPAD} &mdash; the source device
277has gamepad buttons such as {@link android.view.KeyEvent#KEYCODE_BUTTON_A}
278or {@link android.view.KeyEvent#KEYCODE_BUTTON_B}. Implies
279{@link android.view.InputDevice#SOURCE_CLASS_BUTTON}</li>
280<li>{@link android.view.InputDevice#SOURCE_JOYSTICK} &mdash; the source device
281has joystick axes. Implies SOURCE_CLASS_JOYSTICK.</li>
282</ul>
283
284<p>To describe motion events from these new sources, as well as those from mice
285and trackballs, the platform now defines axis codes on {@link
286android.view.MotionEvent}, similar to how it defines key codes on {@link
287android.view.KeyEvent}. New axis codes for joysticks
288and game controllers include
289{@link android.view.MotionEvent#AXIS_HAT_X}, {@link
290android.view.MotionEvent#AXIS_HAT_Y}, {@link
291android.view.MotionEvent#AXIS_RTRIGGER}, {@link
292android.view.MotionEvent#AXIS_ORIENTATION}, {@link
293android.view.MotionEvent#AXIS_THROTTLE}, and many others.
294Existing {@link android.view.MotionEvent} axes are represented by {@link
295android.view.MotionEvent#AXIS_X}, {@link android.view.MotionEvent#AXIS_Y},
296{@link android.view.MotionEvent#AXIS_PRESSURE}, {@link
297android.view.MotionEvent#AXIS_SIZE}, {@link
298android.view.MotionEvent#AXIS_TOUCH_MAJOR}, {@link
299android.view.MotionEvent#AXIS_TOUCH_MINOR}, {@link
300android.view.MotionEvent#AXIS_TOOL_MAJOR}, {@link
301android.view.MotionEvent#AXIS_TOOL_MINOR}, and {@link
302android.view.MotionEvent#AXIS_ORIENTATION}.</p>
303
304<p>Additionally, {@link android.view.MotionEvent} defines a number of generic
305axis codes that are used when the framework does not know how to map a
306particular axis. Specific devices can use the generic axis codes to pass custom
307motion data to applications. For a full list of axes and their intended
308interpretations, see the {@link android.view.MotionEvent} class documentation.
309</p>
310
311<p>The platform provides motion events to applications in batches, so a single
312event may contain a current position and multiple so-called historical movements.
313Applications should use {@link android.view.MotionEvent#getHistorySize()} to get
314the number of historical samples, then retrieve and process all historical
315samples in order using {@link
316android.view.MotionEvent#getHistoricalAxisValue(int, int, int)
317getHistoricalAxisValue()}. After that, applications should process the current
318sample using {@link android.view.MotionEvent#getAxisValue(int) getAxisValue()}.
319</p>
320
321<p>Some axes can be retrieved using special accessor methods. For example,
322instead of calling {@link android.view.MotionEvent#getAxisValue(int)
323getAxisValue()}, applications can call {@link android.view.MotionEvent#getX(int)
324getX()}. Axes that have built-in accessors include {@link
325android.view.MotionEvent#AXIS_X}, {@link android.view.MotionEvent#AXIS_Y},
326{@link android.view.MotionEvent#AXIS_PRESSURE}, {@link
327android.view.MotionEvent#AXIS_SIZE}, {@link
328android.view.MotionEvent#AXIS_TOUCH_MAJOR}, {@link
329android.view.MotionEvent#AXIS_TOUCH_MINOR}, {@link
330android.view.MotionEvent#AXIS_TOOL_MAJOR}, {@link
331android.view.MotionEvent#AXIS_TOOL_MINOR}, and {@link
332android.view.MotionEvent#AXIS_ORIENTATION}.</p>
333
334<p>Each input device has a unique, system-assigned ID and may also provide
335multiple sources. When a device provides multiple sources, more than one source
336can provide axis data using the same axis. For example, a touch event coming
337from the touch source uses the X axis for screen position data, while a joystick
338event coming from the joystick source will use the X axis for the stick position
339instead. For this reason, it's important for applications to interpret axis
340values according to the source from which they originate. When handling a motion
341event, applications should use methods on the {@link android.view.InputDevice}
342class to determine the axes supported by a device or source. Specifically,
343applications can use {@link android.view.InputDevice#getMotionRanges()
344getMotionRanges()} to query for all axes of a device or all axes of a given
345source of the device. In both cases, the range information for axes returned in
346the {@link android.view.InputDevice.MotionRange} object specifies the source for
347each axis value.</p>
348
349<p>Finally, since the motion events from joysticks, gamepads, mice, and
350trackballs are not touch events, the platform adds a new callback method for
351passing them to a {@link android.view.View} as "generic" motion events.
352Specifically, it reports the non-touch motion events to
353{@link android.view.View}s through a call to {@link
354android.view.View#onGenericMotionEvent(android.view.MotionEvent)
355onGenericMotionEvent()}, rather than to {@link
356android.view.View#onTouchEvent(android.view.MotionEvent)
357onTouchEvent()}.</p>
358
359<p>The platform dispatches generic motion events differently, depending on the
360event source class. {@link android.view.InputDevice#SOURCE_CLASS_POINTER} events
361go to the {@link android.view.View} under the pointer, similar to how touch
362events work. All others go to the currently focused {@link android.view.View}.
363For example, this means a {@link android.view.View} must take focus in order to
364receive joystick events. If needed, applications can handle these events at the
365level of Activity or Dialog by implementing {@link
366android.view.View#onGenericMotionEvent(android.view.MotionEvent)
367onGenericMotionEvent()} there instead.</p>
368
369<p class="note">To look at a sample application that uses joystick motion
370events, see <a
371href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/
372GameControllerInput.html">GameControllerInput</a> and <a
373href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/
374GameView.html">GameView</a>.</p>
375
376<h3>RTP API</h3>
377
378<p>Android 3.1 exposes an API to its built-in RTP (Real-time Transport Protocol)
379stack, which applications can use to manage on-demand or interactive data
380streaming. In particular, apps that provide VOIP, push-to-talk, conferencing,
381and audio streaming can use the API to initiate sessions and transmit or receive
382data streams over any available network.</p>
383
384<p>The RTP API is available in the {@link android.net.rtp} package. Classes
385include: </p>
386<ul>
387<li>{@link android.net.rtp.RtpStream}, the base class of streams that send and
388receive network packets with media payloads over RTP.</li>
389<li>{@link android.net.rtp.AudioStream}, a subclass of {@link
390android.net.rtp.RtpStream} that carries audio payloads over RTP.</li>
391<li>{@link android.net.rtp.AudioGroup}, a local audio hub for managing and
392mixing the device speaker, microphone, and {@link android.net.rtp.AudioStream}.</li>
393<li>{@link android.net.rtp.AudioCodec}, which holds a collection of codecs that
394you define for an {@link android.net.rtp.AudioStream}.</li>
395</ul>
396
397<p>To support audio conferencing and similar usages, an application instantiates
398two classes as endpoints for the stream:</p>
399
400<ul>
401<li>{@link android.net.rtp.AudioStream} specifies a remote endpoint and consists
402of network mapping and a configured {@link android.net.rtp.AudioCodec}.</li>
403<li>{@link android.net.rtp.AudioGroup} represents the local endpoint for one
404or more {@link android.net.rtp.AudioStream}s. The {@link android.net.rtp.AudioGroup} mixes
405all the {@link android.net.rtp.AudioStream}s and optionally interacts with the device
406speaker and the microphone at the same time.</li>
407</ul>
408
409<p>The simplest usage involves a single remote endpoint and local endpoint.
410For more complex usages, please refer to the limitations described for
411{@link android.net.rtp.AudioGroup}.</p>
412
413<p>To use the RTP API, applications must request permission from the user by
414declaring <code>&lt;uses-permission
415android:name="android.permission.INTERNET"&gt;</code>
416in their manifest files. To acquire the device microphone, the <code>&lt;uses-permission
417android:name="android.permission.RECORD_AUDIO"&gt;</code> permission is also required.</p>
418
419<h3 id="resizewidgets">Resizable app widgets</h3>
420
421<p>Starting in Android 3.1, developers can make their homescreen widgets
422resizeable &mdash; horizontally, vertically, or on both axes. Users touch-hold a
423widget to show its resize handles, then drag the horizontal and/or vertical
424handles to change the size on the layout grid. </p>
425
426<p>Developers can make any Home screen widget resizeable by defining a
427<code>resizeMode</code> attribute in the widget's {@link
428android.appwidget.AppWidgetProviderInfo} metadata. Values for the
429<code>resizeMode</code> attribute include "horizontal", "vertical", and "none".
430To declare a widget as resizeable horizontally and vertically, supply the value
431"horizontal|vertical".
432
433<p>Here's an example: </p>
434
435<pre>&lt;appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
436 android:minWidth="294dp"
437 android:minHeight="72dp"
438 android:updatePeriodMillis="86400000"
439 android:previewImage="@drawable/preview"
440 android:initialLayout="@layout/example_appwidget"
441 android:configure="com.example.android.ExampleAppWidgetConfigure"
442 android:resizeMode="horizontal|vertical" >
443&lt;/appwidget-provider></pre>
444
445<p>For more information about Home screen widgets, see the <a
446href="{@docRoot}guide/topics/appwidgets/index.html">App Widgets</a>
447documentation.</p>
448
449<h3 id="animation" style="margin-top:1.25em;">Animation framework</h3>
450
451<ul>
452<li>New ViewPropertyAnimator class
453 <ul>
454 <li>A new {@link android.view.ViewPropertyAnimator} class provides a
455convenient
456way for developers to animate select properties on {@link android.view.View} objects. The class
457automaties and optimizes the animation of the properties and makes it easier to
458manage multiple simulataneous animations on a {@link android.view.View} object.
459<p>Using the {@link android.view.ViewPropertyAnimator} is straightforward. To animate properties for
460a {@link android.view.View}, call {@link android.view.View#animate()} to
461construct a {@link android.view.ViewPropertyAnimator} object for that {@link android.view.View}. Use the
462methods on the {@link android.view.ViewPropertyAnimator} to specify what property to
463animate and how to animate it. For example, to fade the {@link android.view.View} to transparent,
464call <code>alpha(0);</code>. The {@link android.view.ViewPropertyAnimator} object
465handles the details of configuring the underlying {@link
466android.animation.Animator} class and starting it, then rendering the
467animation.</p></li>
468 </ul>
469</li>
470<li>Animation background color
471 <ul>
472 <li>New {@link android.view.animation.Animation#getBackgroundColor()} and
473 {@link android.view.animation.Animation#setBackgroundColor(int)} methods let
474 you get/set the background color behind animations, for window animations
475only. Currently the background must be black, with any desired alpha level.</li>
476 </ul>
477</li>
478<li>Getting animated fraction from <code>ViewAnimator</code>
479 <ul>
480 <li>A new {@link android.animation.ValueAnimator#getAnimatedFraction()}
481method
482lets you get the current animation fraction &mdash; the elapsed/interpolated
483fraction used in the most recent frame update &mdash; from a {@link
484android.animation.ValueAnimator}.</li>
485 </ul>
486</li>
487</ul>
488
489<h3 "ui">UI framework</h3>
490<ul>
491<li>Forced rendering of a layer
492 <ul>
493 <li>A new {@link android.view.View#buildLayer()} method lets an application
494force a View's layer to be created and the View rendered into it immediately.
495For example, an application could use this method to render a View into its
496layer before starting an animation. If the View is complex, rendering it into
497the layer before starting the animation will avoid skipping frames.</li>
498 </ul>
499</li>
500<li>Camera distance
501 <ul>
502 <li>Applications can use a new method
503{@link android.view.View#setCameraDistance(float)} to set the distance from the
504camera
505to a View. This gives applications improved control over 3D transformations of
506the View, such as rotations. </li>
507 </ul>
508</li>
509<li>Getting a calendar view from a DatePicker
510 <ul>
511 <li>A new {@link android.widget.DatePicker#getCalendarView()} method
512 lets you get a {@link android.widget.CalendarView} from a {@link
513android.widget.DatePicker}
514 instance.</li>
515 </ul>
516</li>
517<li>Getting callbacks when views are detached
518 <ul>
519 <li>A new {@link android.view.View.OnAttachStateChangeListener} lets you
520receive
521callbacks when a View is attached or detached from its window. Use {@link
522android.view.View#addOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) addOnAttachStateChangeListener()}
523to add a listener and {@link
524android.view.View#removeOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) addOnAttachStateChangeListener()} to remove it.</li>
525 </ul>
526</li>
527<li>Fragment breadcrumb listener, new onInflate() signature
528 <ul>
529 <li>A new method, {@link
530android.app.FragmentBreadCrumbs#setOnBreadCrumbClickListener(android.app.FragmentBreadCrumbs.OnBreadCrumbClickListener) setOnBreadCrumbClickListener()},
531provides a hook to let
532applications intercept fragment-breadcrumb clicks and take any action needed
533before going to the backstack entry or fragment that was clicked. </li>
534 <li>In the {@link android.app.Fragment} class, {@link
535android.app.Fragment#onInflate(android.util.AttributeSet, android.os.Bundle)
536onInflate(attrs, savedInstanceState)} is deprecated. Please use {@link
537android.app.Fragment#onInflate(android.app.Activity, android.util.AttributeSet,
538android.os.Bundle) onInflate(activity, attrs, savedInstanceState)} instead.</li>
539 </ul>
540</li>
541<li>Display search result in new tab
542 <ul>
543 <li>An {@link android.app.SearchManager#EXTRA_NEW_SEARCH} data key for {@link
544android.content.Intent#ACTION_WEB_SEARCH} intents lets you open a search in a
545new browser tab, rather than in an existing one.</li>
546 </ul>
547</li>
548
549<li>Drawable text cursor
550 <ul>
551<li>You can now specify a drawable to use as the text cursor using the new
552resource attribute {@link android.R.attr#textCursorDrawable}.</li>
553 </ul>
554</li>
555<li>Setting displayed child in remote views
556 <ul>
557 <li>A new convenience method, {@link
558android.widget.RemoteViews#setDisplayedChild(int, int) setDisplayedChild(viewId,
559childIndex)}, is available in {@link android.widget.RemoteViews} subclasses, to
560let you set the child displayed in {@link android.widget.ViewAnimator} and
561{@link android.widget.AdapterViewAnimator} subclasses such as {@link
562android.widget.AdapterViewFlipper}, {@link android.widget.StackView}, {@link
563android.widget.ViewFlipper}, and {@link android.widget.ViewSwitcher}.</li>
564 </ul>
565</li>
566<li>Generic keys for gamepads and other input devices
567 <ul>
568 <li>{@link android.view.KeyEvent} adds a range of generic keycodes to
569 accommodate gamepad buttons. The class also adds
570 {@link android.view.KeyEvent#isGamepadButton(int)} and several other
571 helper methods for working with keycodes.</li>
572 </ul>
573</li>
574</ul>
575
576<h3 id="graphics" style="margin-top:1.3em;">Graphics</h3>
577
578<ul>
579<li>Helpers for managing bitmaps
580 <ul>
581 <li>{@link android.graphics.Bitmap#setHasAlpha(boolean)} lets an app indicate that
582all of the pixels in a Bitmap are known to be opaque (false) or that some of the
583pixels may contain non-opaque alpha values (true). Note, for some configs (such
584as RGB_565) this call is ignored, since it does not support per-pixel alpha
585values. This is meant as a drawing hint, as in some cases a bitmap that is known
586to be opaque can take a faster drawing case than one that may have non-opaque
587per-pixel alpha values. </li>
588 <li>{@link android.graphics.Bitmap#getByteCount()} gets a Bitmap's size in
589bytes.</li>
590 <li>{@link android.graphics.Bitmap#getGenerationId()} lets an application find
591out whether a Bitmap has been modified, such as for caching.</li>
592 <li>{@link android.graphics.Bitmap#sameAs(android.graphics.Bitmap)} determines
593whether a given Bitmap differs from the current Bitmap, in dimension,
594configuration, or pixel data. </li>
595 </ul>
596</li>
597<li>Setting camera location and rotation
598 <ul>
599 <li>{@link android.graphics.Camera} adds two new methods {@link
600android.graphics.Camera#rotate(float, float, float) rotate()} and {@link
601android.graphics.Camera#setLocation(float, float, float) setLocation()} for
602control of the
603camera's location, for 3D transformations.</li>
604</ul>
605</li>
606</ul>
607
608<h3 id="network" style="margin-top:1.25em;">Network</h3>
609
610<ul>
611<li>High-performance Wi-Fi lock
612 <ul>
613 <li>A new high-performance Wi-Fi lock lets applications maintain
614high-performance Wi-Fi connections even when the device screen is off.
615Applications that stream music, video, or voice for long periods can acquire the
616high-performance Wi-Fi lock to ensure streaming performance even when the screen
617is off. Because it uses more power, applications should acquire the
618high-performance Wi-Fi when there is a need for a long-running active
619connection.
620<p>To create a high-performance lock, pass {@link
621android.net.wifi.WifiManager#WIFI_MODE_FULL_HIGH_PERF} as the lock mode in a
622call to {@link android.net.wifi.WifiManager#createWifiLock(int,
623java.lang.String) createWifiLock()}.</p></li>
624 </ul>
625</li>
626<li>More traffic stats
627 <ul>
628 <li>Applications can now access statistics about more types of network usage
629using new methods in {@link android.net.TrafficStats}. Applications can use the
630methods to get UDP stats, packet count, TCP transmit/receive payload bytes and
631segments for a given UID.</li>
632 </ul>
633</li>
634<li>SIP auth username
635 <ul>
636 <li>Applications can now get and set the SIP auth username for a profile
637using
638the new methods {@link android.net.sip.SipProfile#getAuthUserName()
639getAuthUserName()} and {@link
640android.net.sip.SipProfile.Builder#setAuthUserName(java.lang.String)
641setAuthUserName()}.</li>
642 </ul>
643</li>
644</ul>
645
646
647<h3 id="download" style="margin-top:1.25em;">Download Manager</h3>
648<ul>
649<li>Handling of completed downloads
650 <ul>
651 <li>Applications can now initiate downloads that notify users only on
652completion. To initiate this type of download, applications pass {@link
653android.app.DownloadManager.Request#VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION}
654in the {@link
655android.app.DownloadManager.Request#setNotificationVisibility(int)
656setNotificationVisibility()} method of
657the a request object.</li>
658 <li>A new method, {@link
659android.app.DownloadManager#addCompletedDownload(java.lang.String,
660java.lang.String, boolean, java.lang.String, java.lang.String, long, boolean)
661addCompletedDownload()}, lets an application add a file to the
662downloads database, so that it can be managed by the Downloads application.</li>
663 </ul>
664</li>
665<li>Show downloads sorted by size
666 <ul>
667 <li>Applications can start the Downloads application in sort-by-size mode by
668adding the new extra {@link
669android.app.DownloadManager#INTENT_EXTRAS_SORT_BY_SIZE} to an {@link
670android.app.DownloadManager#ACTION_VIEW_DOWNLOADS} intent.</li>
671 </ul>
672</li>
673</ul>
674
675<h3 id="ime" style="margin-top:1.25em;">IME framework</h3>
676
677<ul>
678<li>Getting an input method's extra value key
679 <ul><li>The {@link android.view.inputmethod.InputMethodSubtype} adds the
680method
681{@link
682android.view.inputmethod.InputMethodSubtype#containsExtraValueKey(java.lang.String) containsExtraValueKey()} to check whether an ExtraValue string is stored
683for the subtype and
684the method {@link
685android.view.inputmethod.InputMethodSubtype#getExtraValueOf(java.lang.String)
686getExtraValueOf()} to extract a specific key value from the ExtraValue hashmap.
687</li>
688 </ul>
689</li>
690</ul>
691
692<h3 id="media" style="margin-top:1.25em;">Media</h3>
693
694<ul>
695<li>New streaming audio formats
696 <ul>
697 <li>The media framework adds built-in support for raw ADTS AAC content, for
698improved streaming audio, as well as support for FLAC audio, for highest quality
699(lossless) compressed audio content. See the <a
700href="{@docRoot}guide/appendix/media-formats.html">Supported Media Formats</a>
701document for more information.</p></li>
702 </ul>
703</li>
704</ul>
705
706<h3 id="launchcontrols" style="margin-top:1.25em;">Launch controls on stopped
707applications</h3>
708
709<p>Starting from Android 3.1, the system's package manager keeps track of
710applications that are in a stopped state and provides a means of controlling
711their launch from background processes and other applications.</p>
712
713<p>Note that an application's stopped state is not the same as an Activity's
714stopped state. The system manages those two stopped states separately.</p>
715
716<p>The platform defines two new intent flags that let a sender specify
717whether the Intent should be allowed to activate components in stopped
718application.</p>
719
720<ul>
721<li>{@link android.content.Intent#FLAG_INCLUDE_STOPPED_PACKAGES} &mdash;
722Include intent filters of stopped applications in the list of potential targets
723to resolve against. </li>
724<li>{@link android.content.Intent#FLAG_EXCLUDE_STOPPED_PACKAGES} &mdash;
725Exclude intent filters of stopped applications from the list of potential
726targets.</li>
727</ul>
728
729<p>When neither or both of these flags is defined in an intent, the default
730behavior is to include filters of stopped applications in the list of
731potential targets.</p>
732
733<p>Note that the system adds {@link
734android.content.Intent#FLAG_EXCLUDE_STOPPED_PACKAGES} <em>to all broadcast
735intents</em>. It does this to prevent broadcasts from background services from
736inadvertently or unnecessarily launching components of stoppped applications.
737A background service or application can override this behavior by adding the
738{@link android.content.Intent#FLAG_INCLUDE_STOPPED_PACKAGES} flag to broadcast
739intents that should be allowed to activate stopped applications.</p>
740
741<p>Applications are in a stopped state when they are first installed but are not
742yet launched and when they are manually stopped by the user (in Manage
743Applications).</p>
744
745<h3 id="installnotification">Notification of application first launch and upgrade</h3>
746
747<p>The platform adds improved notification of application first launch and
748upgrades through two new intent actions:</p>
749
750<ul>
751<li>{@link android.content.Intent#ACTION_PACKAGE_FIRST_LAUNCH} &mdash; Sent to
752the installer package of an application when that application is first launched
753(that is, the first time it is moved out of a stopped state). The data
754contains the name of the package. </li>
755
756<li>{@link android.content.Intent#ACTION_MY_PACKAGE_REPLACED} &mdash; Notifies
757an application that it was updated, with a new version was installed over
758an existing version. This is only sent to the application that was replaced. It
759does not contain any additional data. To receive it, declare an intent filter
760for this action. You can use the intent to trigger code that helps get your
761application back in proper running shape after an upgrade.
762
763<p>This intent is sent directly to the application, but only if the application
764was upgraded while it was in started state (not in a stopped state).</p></li>
765
766</ul>
767
768<h3 if="other">Core utilities</h3>
769
770<ul>
771<li>LRU cache
772 <ul>
773 <li>A new {@link android.util.LruCache} class lets your applications benefit
774from efficient caching. Applications can use the class to reduce the time spent
775computing or downloading data from the network, while maintaining a sensible
776memory footprint for the cached data.{@link android.util.LruCache} is a cache
777that holds strong references to a limited number of values. Each time a value is
778accessed, it is moved to the head of a queue. When a value is added to a full
779cache, the value at the end of that queue is evicted and may become eligible for
780garbage collection.</li>
781 </ul>
782</li>
783<li>File descriptor as <code>int</code>
784 <ul>
785 <li>You can now get the native file descriptor int for a {@link
786android.os.ParcelFileDescriptor} using either of the new methods {@link
787android.os.ParcelFileDescriptor#getFd()} or {@link
788android.os.ParcelFileDescriptor#detachFd()}. </li>
789 </ul>
790</li>
791</ul>
792
793
794
795
796
797
798<h3 id="webkit" style="margin-top:1.25em;">WebKit</h3>
799
800<ul>
801
802<li>File scheme cookies
803 <ul>
804 <li>The {@link android.webkit.CookieManager} now supports cookies that use
805the
806<code>file:</code> URI scheme. You can use {@link
807android.webkit.CookieManager#setAcceptFileSchemeCookies(boolean)
808setAcceptFileSchemeCookies()} to
809enable/disable support for file scheme cookies, before constructing an instance
810of <code>WebView</code> or <code>CookieManager</code>. In a
811<code>CookieManager</code> instance, you can check whether file scheme cookies
812is enabled by calling {@link
813android.webkit.CookieManager#allowFileSchemeCookies()}.</li>
814 </ul>
815</li>
816<li>Notification of login request
817 <ul>
818 <li>To support the browser autologin features introduced in Android 3.0, the
819new
820method {@link
821android.webkit.WebViewClient#onReceivedLoginRequest(android.webkit.WebView,java.lang.String, java.lang.String, java.lang.String) onReceivedLoginRequest()}
822notifies the host
823application that an autologin request for the user was processed. </li>
824 </ul>
825</li>
826<li>Removed classes and interfaces
827 <ul>
828 <li>Several classes and interfaces were removed from the public API, after
829previously being in deprecated state. See the <a
830href="{@docRoot}sdk/api_diff/{@sdkPlatformApiLevel}/changes.html">API
831Differences Report</a> for more information.</p></li>
832 </ul>
833 </li>
834</ul>
835
836
837
838<h3 id="browser" style="margin-top:1.25em;">Browser</h3>
839
840<p>The Browser application adds the following features to support web
841applications:</p>
842
843<ul>
844<li>Support for inline playback of video embedded in HTML5
845<code>&lt;video&gt;</code> tag. Playback is hardware-accelerated where possible.
846</li>
847<li>Layer support for fixed position elements for all sites (mobile and
848desktop).</li>
849</ul>
850
851
852
853
854
855<h3 id="features">New feature constants</h3>
856
857<p>The platform adds new hardware feature constants that developers can declare
858in their application manifests, to inform external entities such as Android
859Market of the application's requirement for new hardware capabilities supported
860in this version of the platform. Developers declare these and other feature
861constants in <a
862href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code
863&lt;uses-feature&gt;}</a> manifest elements.
864
865<ul>
866 <li>{@link android.content.pm.PackageManager#FEATURE_USB_ACCESSORY
867android.hardware.usb.accessory} &mdash; The application uses the <a href="#usb">USB
868API</a> to communicate with external hardware devices connected over USB and
869function as hosts.</li>
870 <li>{@link android.content.pm.PackageManager#FEATURE_USB_HOST
871android.hardware.usb.host} &mdash; The application uses the <a href="#usb">USB API</a>
872to communicate with external hardware devices connected over USB and function as
873devices.</li>
874</ul>
875
876<p>Android Market filters applications based on features declared in <a
877href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code
878&lt;uses-feature&gt;}</a> manifest elements. For more information about
879declaring features in an application manifest, read <a
880href="{docRoot}guide/appendix/market-filters.html">Android Market
881Filters</a>.</p>
882
883
884
885<h3 id="api-diff">API Differences Report</h3>
886
887<p>For a detailed view of all API changes in Android {@sdkPlatformVersion} (API
888Level
889{@sdkPlatformApiLevel}), see the <a
890href="{@docRoot}sdk/api_diff/{@sdkPlatformApiLevel}/changes.html">API
891Differences Report</a>.</p>
892
893
894
895
896
897<h2 id="api-level">API Level</h2>
898
899<p>The Android {@sdkPlatformVersion} platform delivers an updated version of
900the framework API. The Android {@sdkPlatformVersion} API
901is assigned an integer identifier &mdash;
902<strong>{@sdkPlatformApiLevel}</strong> &mdash; that is
903stored in the system itself. This identifier, called the "API Level", allows the
904system to correctly determine whether an application is compatible with
905the system, prior to installing the application. </p>
906
907<p>To use APIs introduced in Android {@sdkPlatformVersion} in your application,
908you need compile the application against the Android library that is provided in
909the Android {@sdkPlatformVersion} SDK platform. Depending on your needs, you
910might
911also need to add an <code>android:minSdkVersion="{@sdkPlatformApiLevel}"</code>
912attribute to the <code>&lt;uses-sdk&gt;</code> element in the application's
913manifest.</p>
914
915<p>For more information about how to use API Level, see the <a
916href="{@docRoot}guide/appendix/api-levels.html">API Levels</a> document. </p>
917
918
919<h2 id="apps">Built-in Applications</h2>
920
921<p>The system image included in the downloadable platform provides these
922built-in applications:</p>
923
924<table style="border:0;padding-bottom:0;margin-bottom:0;">
925<tr>
926<td style="border:0;padding-bottom:0;margin-bottom:0;">
927<ul>
928<li>API Demos</li>
929<li>Browser</li>
930<li>Calculator</li>
931<li>Camera</li>
932<li>Clock</li>
933<li>Contacts</li>
934<li>Custom Locale</li>
935<li>Dev Tools</li>
936<li>Downloads</li>
937<li>Email</li>
938</ul>
939</td>
940<td style="border:0;padding-bottom:0;margin-bottom:0;padding-left:5em;">
941<ul>
942<li>Gallery</li>
943<li>Gestures Builder</li>
944<li>Messaging</li>
945<li>Music</li>
946<li>Search</li>
947<li>Settings</li>
948<li>Spare Parts</li>
949<li>Speech Recorder</li>
950<li>Widget Preview</li>
951</ul>
952</td>
953</tr>
954</table>
955
956
957<h2 id="locs" style="margin-top:.75em;">Locales</h2>
958
959<p>The system image included in the downloadable SDK platform provides a variety
960of
961built-in locales. In some cases, region-specific strings are available for the
962locales. In other cases, a default version of the language is used. The
963languages that are available in the Android 3.0 system
964image are listed below (with <em>language</em>_<em>country/region</em> locale
965descriptor).</p>
966
967<table style="border:0;padding-bottom:0;margin-bottom:0;">
968<tr>
969<td style="border:0;padding-bottom:0;margin-bottom:0;">
970<ul>
971<li>Arabic, Egypt (ar_EG)</li>
972<li>Arabic, Israel (ar_IL)</li>
973<li>Bulgarian, Bulgaria (bg_BG)</li>
974<li>Catalan, Spain (ca_ES)</li>
975<li>Czech, Czech Republic (cs_CZ)</li>
976<li>Danish, Denmark(da_DK)</li>
977<li>German, Austria (de_AT)</li>
978<li>German, Switzerland (de_CH)</li>
979<li>German, Germany (de_DE)</li>
980<li>German, Liechtenstein (de_LI)</li>
981<li>Greek, Greece (el_GR)</li>
982<li>English, Australia (en_AU)</li>
983<li>English, Canada (en_CA)</li>
984<li>English, Britain (en_GB)</li>
985<li>English, Ireland (en_IE)</li>
986<li>English, India (en_IN)</li>
987<li>English, New Zealand (en_NZ)</li>
988<li>English, Singapore(en_SG)</li>
989<li>English, US (en_US)</li>
990<li>English, Zimbabwe (en_ZA)</li>
991<li>Spanish (es_ES)</li>
992<li>Spanish, US (es_US)</li>
993<li>Finnish, Finland (fi_FI)</li>
994<li>French, Belgium (fr_BE)</li>
995<li>French, Canada (fr_CA)</li>
996<li>French, Switzerland (fr_CH)</li>
997<li>French, France (fr_FR)</li>
998<li>Hebrew, Israel (he_IL)</li>
999<li>Hindi, India (hi_IN)</li>
1000</ul>
1001</td>
1002<td style="border:0;padding-bottom:0;margin-bottom:0;padding-left:5em;">
1003<li>Croatian, Croatia (hr_HR)</li>
1004<li>Hungarian, Hungary (hu_HU)</li>
1005<li>Indonesian, Indonesia (id_ID)</li>
1006<li>Italian, Switzerland (it_CH)</li>
1007<li>Italian, Italy (it_IT)</li>
1008<li>Japanese (ja_JP)</li>
1009<li>Korean (ko_KR)</li>
1010<li>Lithuanian, Lithuania (lt_LT)</li>
1011<li>Latvian, Latvia (lv_LV)</li>
1012<li>Norwegian bokmål, Norway (nb_NO)</li>
1013<li>Dutch, Belgium (nl_BE)</li>
1014<li>Dutch, Netherlands (nl_NL)</li>
1015<li>Polish (pl_PL)</li>
1016<li>Portuguese, Brazil (pt_BR)</li>
1017<li>Portuguese, Portugal (pt_PT)</li>
1018<li>Romanian, Romania (ro_RO)</li>
1019<li>Russian (ru_RU)</li></li>
1020<li>Slovak, Slovakia (sk_SK)</li>
1021<li>Slovenian, Slovenia (sl_SI)</li>
1022<li>Serbian (sr_RS)</li>
1023<li>Swedish, Sweden (sv_SE)</li>
1024<li>Thai, Thailand (th_TH)</li>
1025<li>Tagalog, Philippines (tl_PH)</li>
1026<li>Turkish, Turkey (tr_TR)</li>
1027<li>Ukrainian, Ukraine (uk_UA)</li>
1028<li>Vietnamese, Vietnam (vi_VN)</li>
1029<li>Chinese, PRC (zh_CN)</li>
1030<li>Chinese, Taiwan (zh_TW)</li>
1031</td>
1032</tr>
1033</table>
1034
1035<p class="note"><strong>Note:</strong> The Android platform may support more
1036locales than are included in the SDK system image. All of the supported locales
1037are available in the <a href="http://source.android.com/">Android Open Source
1038Project</a>.</p>
1039
1040<h2 id="skins">Emulator Skins</h2>
1041
1042<p>The downloadable platform includes the following emulator skin:</p>
1043
1044<ul>
1045 <li>
1046 WXGA (1280x800, medium density, xlarge screen)
1047 </li>
1048</ul>
1049
1050<p>For more information about how to develop an application that displays
1051and functions properly on all Android-powered devices, see <a
1052href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
1053Screens</a>.</p>