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