1page.title=Android 3.2 APIs
2excludeFromSuggestions=true
3sdk.platform.version=3.2
4sdk.platform.apiLevel=13
5@jd:body
6
7<div id="qv-wrapper">
8<div id="qv">
9
10<h2>In this document</h2>
11<ol>
12  <li><a href="#highlights">Highlights</a></li>
13  <li><a href="#api">API Overview</a></li>
14  <li><a href="#api-level">API Level</a></li>
15</ol>
16
17<h2>Reference</h2>
18<ol>
19<li><a
20href="{@docRoot}sdk/api_diff/13/changes.html">API
21Differences Report &raquo;</a> </li>
22</ol>
23
24</div>
25</div>
26
27
28<p><em>API Level:</em>&nbsp;<strong>{@sdkPlatformApiLevel}</strong></p>
29
30<p>Android 3.2 ({@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}) is an incremental platform release that adds new
31capabilities for users and developers. The sections below provide an overview
32of the new features and developer APIs.</p>
33
34<p>For developers, the Android {@sdkPlatformVersion} platform is available as a
35downloadable component for the Android SDK. The downloadable platform includes
36an Android library and system image, as well as a set of emulator skins and
37more. To get started developing or testing against Android {@sdkPlatformVersion},
38use the Android SDK Manager to download the platform into your SDK.</p>
39
40
41
42<h2 id="highlights" style="margin-top:1.5em;">Platform Highlights</h2>
43
44<h3>New user features</h3>
45
46<ul>
47<li><strong>Optimizations for a wider range of tablets</strong>
48
49<p>Android 3.2 includes a variety of optimizations across the system
50to ensure a great user experience on a wider range of tablet devices.</p></li>
51
52<li><strong>Compatibility zoom for fixed-sized apps</strong>
53
54<p>Android 3.2 introduces a new <em>compatibility zoom</em> mode that gives
55users a new way to view fixed-sized apps on larger devices. The new mode provides a
56pixel-scaled alternative to the standard UI stretching for apps that are not
57designed to run on larger screen sizes, such as on tablets. The new mode is
58accessible to users from a menu icon in the system bar, for apps that need
59compatibility support.</p></li>
60
61<li><strong>Media sync from SD card</strong>
62<p>On devices that support an SD card, users can now load media files directly
63from the SD card to apps that use them. A system facility makes the files
64accessible to apps from the system media store.</p></li>
65</ul>
66
67
68<h3>New developer features</h3>
69
70<ul>
71<li><strong>Extended API for managing screens support</strong>
72
73<p>Android 3.2 introduces extensions to the platform's screen support API to
74give developers additional ways to manage application UI across the range of
75Android-powered devices. The API includes new resource qualifiers and new
76manifest attributes that give you more precise control over how your
77apps are displayed on different sizes, rather than relying on generalized
78size categories.</p>
79
80<p>To ensure the best possible display for fixed-sized apps and apps with limited
81support for various screen sizes, the platform also provides a new zoom
82compatibility mode that renders the UI on a smaller screen area, then scales it
83up to fill the space available on the display. For more information about the
84screen support API and the controls it provides, see the sections below. </p></li>
85</ul>
86
87
88<h2 id="api">API Overview</h2>
89
90<h3 id="usb">Screens Support APIs</h3>
91
92<p>Android 3.2 introduces new screens support APIs that give you more
93control over how their applications are displayed across different screen sizes.
94The API builds on the existing screens-support API, including the platform's
95generalized screen density model, but extends it with the ability to precisely
96target specific screen ranges by their dimensions, measured in
97density-independent pixel units (such as 600dp or 720dp wide), rather than
98by their generalized screen sizes (such as large or xlarge)</p>
99
100<p>When designing an application's UI, you can still rely on the platform to
101provide density abstraction, which means that applications do not need to
102compensate for the differences in actual pixel density across devices. You
103can design the application UI according to the amount of horizontal or vertical
104space available. The platform expresses the amount of space available using three new
105characteristics: <em>smallestWidth</em>, <em>width</em>, and
106<em>height</em>.</p>
107
108<ul>
109<li>A screen's <em>smallestWidth</em> is its fundamental minimum size,
110measured in density-independent pixel ("dp") units. Of the screen's height or
111width, it is the shorter of the two. For a screen in portrait orientation, the
112smallestWidth is normally based on its width, while in landscape orientation it is based
113on its height. In all cases, the smallestWidth is derived from a fixed characteristic of the
114screen and the value does not change, regardless of orientation. The smallestWidth
115is important for applications because it represents the shortest possible width
116in which the application UI will need to be drawn, not including screen areas
117reserved by the system.
118</li>
119
120<li>In contrast, a screen's <em>width</em> and <em>height</em> represent the
121current horizontal or vertical space available for application layout, measured
122in "dp" units, not including screen areas reserved by the system. The width and
123height of a screen change when the user switches orientation between landscape
124and portrait. </li>
125
126</ul>
127
128<p>The new screens support API is designed to let you manage application UI
129according to the smallestWidth of the current screen. You can also manage the
130UI according to current width or height, as needed. For those purposes, the API
131provides these tools:</p>
132
133<ul>
134<li>New resource qualifiers for targeting layouts and other resources to a
135minimum smallestWidth, width, or height, and</li>
136<li>New manifest attributes, for specifying the app's maximum
137screen compatibility range</li>
138</ul>
139
140<p>Additionally, applications can still query the system and manage UI and
141resource loading at runtime, as in the previous versions of the platform.</p>
142
143<p>Since the new API lets you target screens more directly through smallestWidth,
144width, and height, it's helpful to understand the typical
145characteristics of the different screen types. The table below provides some
146examples, measured in "dp" units. </p>
147
148<p class="caption"><strong>Table 1.</strong> Typical devices, with density
149and size in dp.</p>
150
151<table>
152<tr>
153<th>Type</th>
154<th>Density (generalized)</th>
155<th>Dimensions (dp)</th>
156<th>smallestWidth (dp)</th>
157</tr>
158<tr>
159<td>Baseline phone</td>
160<td>mdpi</td>
161<td>320x480</td>
162<td>320</td>
163</td>
164<tr>
165<td>Small tablet/large phone</td>
166<td>mdpi</td>
167<td>480x800</td>
168<td>480</td>
169</tr>
170<tr>
171<td>7-inch tablet</td>
172<td>mdpi</td>
173<td>600x1024</td>
174<td>600</td>
175</tr>
176<tr>
177<td>10-inch tablet</td>
178<td>mdpi</td>
179<td>800x1280</td>
180<td>800</td>
181</tr>
182</table>
183
184<p>The sections below provide more information about the new screen qualifiers
185and manifest attributes. For complete information about how to use the screen
186support API, see <a
187href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
188Screens</a>.</p>
189
190<h4>New resource qualifiers for screens support</h4>
191
192<p>The new resource qualifiers in Android 3.2 let you better target your layouts
193for ranges of screen sizes. Using the qualifiers, you can create resource
194configurations designed for a specific minimum smallestWidth, current width, or
195current height, measured in density-independent pixels.</p>
196
197<p>The new qualifiers are:</p>
198<ul>
199<li><code>swNNNdp</code> &mdash; Specifies the minimum smallestWidth on which
200the resource should be used, measured in "dp" units. As mentioned above, a
201screen's smallestWidth is constant, regardless of orientation. Examples:
202<code>sw320dp</code>, <code>sw720dp</code>, <code>sw720dp</code>.</li>
203
204<li><code>wNNNdp</code> and <code>hNNNdp</code> &mdash; Specifies the minimum
205width or height on which the resource should be used, measured in "dp" units. As
206mentioned above, a screen's width and height are relative to the orientation of
207the screen and change whenever the orientation changes. Examples:
208<code>w320dp</code>, <code>w720dp</code>, <code>h1024dp</code>.</p></li>
209</ul>
210
211<p>You can also create multiple overlapping resource configurations if needed.
212For example, you could tag some resources for use on any screen wider than 480
213dp, others for wider than 600  dp, and others for wider than 720 dp. When
214multiple resource configurations are qualified for a given screen, the system
215selects the configuration that is the closest match. For precise control over
216which resources are loaded on a given screen, you can tag resources with one
217qualifier or combine several new or existing qualifiers.
218
219<p>Based on the typical dimensions listed earlier, here are some examples of how
220you could use the new qualifiers:</p>
221
222<pre class="classic prettyprint">res/layout/main_activity.xml   # For phones
223res/layout-sw600dp/main_activity.xml   # For 7” tablets
224res/layout-sw720dp/main_activity.xml   # For 10” tablets
225res/layout-w600dp/main_activity.xml   # Multi-pane when enough width
226res/layout-sw600dp-w720dp/main_activity.xml   # For large width</pre>
227
228<p>Older versions of the platform will ignore the new qualifiers, so you can
229mix them as needed to ensure that your app looks great on any device. Here
230are some examples:</p>
231
232<pre class="classic prettyprint">res/layout/main_activity.xml   # For phones
233res/layout-xlarge/main_activity.xml   # For pre-3.2 tablets
234res/layout-sw600dp/main_activity.xml   # For 3.2 and up tablets</pre>
235
236<p>For complete information about how to use the new qualifiers, see <a href="{@docRoot}guide/practices/screens_support.html#NewQualifiers">Using new
237size qualifiers</a>.</p>
238
239<h4>New manifest attributes for screen-size compatibility</h4>
240
241<p>The framework offers a new set of <a
242href="{@docRoot}guide/topics/manifest/supports-screens-element.html"><code>&lt;supports-screens&gt;</code></a> manifest attributes that let
243you manage your app's support for different screen sizess.
244Specifically, you can specify the largest and smallest screens on which your app
245is designed to run, as well as the largest screen on which it is designed run
246without needing the system's new <a href="{@docRoot}guide/practices/screen-compat-mode.html">screen
247compatibility mode</a>. Like the resource qualifiers described above, the new
248manifest attributes specify the range of screens that the application supports,
249as specified by the smallestWidth. </p>
250
251<p>The new manifest attributes for screen support are: </p>
252
253<ul>
254<li><code>android:compatibleWidthLimitDp="<em>numDp"</em></code> &mdash; This
255attribute lets you specify the maximum smallestWidth on which the application
256can run without needing compatibility mode. If the current screen is larger than
257the value specified, the system displays the application in normal mode but
258allows the user to optionally switch to compatibility mode through a setting in
259the system bar.</li>
260
261<li><code>android:largestWidthLimitDp="<em>numDp</em>"</code> &mdash; This
262attribute lets you specify the maximum smallestWidth on which the application
263is designed to run.  If the current screen is larger than the value specified,
264the system forces the application into screen compatibility mode, to ensure best
265display on the current screen.</li>
266
267<li><code>android:requiresSmallestWidthDp="<em>numDp"</em></code> &mdash; This
268attribute lets you specify the minimum smallestWidth on which the application
269can run. If the current screen is smaller than the value specified, the system
270considers the application incompatible with the device, but does not prevent it
271from being installed and run.</li>
272</ul>
273
274<p class="note"><strong>Note:</strong> Google Play does not currently filter
275apps based on any of the attributes above. Support for filtering will be
276added in a later platform release. Applications that require
277filtering based on screen size can use the existing <code>&lt;supports-screens&gt;</code>
278attributes.</p>
279
280<p>For complete information about how to use the new attributes, see <a href="{@docRoot}guide/practices/screens_support.html#DeclaringScreenSizeSupport">Declaring
281screen size support</a>.</p>
282
283<h4>Screen compatibility mode</h4>
284
285<p>Android 3.2 provides a new screen compatibility mode for applications
286explicitly declaring that they do not support screens as large as the one on
287which they are running. This new "zoom" mode is a pixel-scaled &mdash; it
288renders the application in a smaller screen area and then scales the pixels to
289fill the current screen.</p>
290
291<p>By default, the system offers screen compatibility mode as an user option, for apps
292that require it. Users can turn the zoom mode on and off using a control available
293in the system bar. </p>
294
295<p>Because the new screen compatibility mode may not be appropriate for all
296applications, the platform allows the application to disable it using manifest
297attributes. When disabled by the app, the system does not offer "zoom" compatibility
298mode as an option for users when the app is running.</p>
299
300<p class="note"><strong>Note:</strong> For important information about how
301to control compatibility mode in your applications, please review the <a
302href="http://android-developers.blogspot.com/2011/07/new-mode-for-apps-on-large-
303screens.html">New Mode for Apps on Large Screens</a> article on the Android
304Developers Blog. </p>
305
306<h4>New screen density for 720p televisions and similar devices</h4>
307
308<p>To meet the needs of applications running on 720p televisions or similar with
309moderate density screens, Android 3.2 introduces a new generalized density,
310<code>tvdpi</code>, with an approximate dpi of 213. Applications can query for
311the new density in {@link android.util.DisplayMetrics#densityDpi} and can use
312the new <code>tvdpi</code> qualifier to tag resources for televisions and
313similar devices. For example:</p>
314
315<pre class="classic prettyprint">res/drawable-tvdpi/my_icon.png   # Bitmap for tv density</pre>
316
317<p>In general, applications should not need to work with this density. For situations
318where output is needed for a 720p screen, the UI elements can be scaled
319automatically by the platform.</p>
320
321
322<h3 id="ui" style="margin-top:1.25em;">UI framework</h3>
323<ul>
324<li>Fragments
325  <ul>
326    <li>New {@link android.app.Fragment.SavedState} class holds the state
327    information retrieved from a fragment instance through
328    {@link android.app.FragmentManager#saveFragmentInstanceState(android.app.Fragment) saveFragmentInstanceState()}.</li>
329    <li>New method {@link android.app.FragmentManager#saveFragmentInstanceState(android.app.Fragment) saveFragmentInstanceState()}
330    saves the current instance state of
331    the given Fragment. The state can be used later when creating a new instance
332    of the Fragment that matches the current state.</li>
333    <li>New method {@link android.app.Fragment#setInitialSavedState(SavedState) setInitialSavedState()}
334    sets the initial saved state for a Fragment when first constructed.</li>
335    <li>New {@link android.app.Fragment#onViewCreated(android.view.View, android.os.Bundle)
336    onViewCreated()} callback method notifies the Fragment that
337    {@link android.app.Fragment#onCreateView(LayoutInflater, ViewGroup, Bundle) onCreateView()}
338    has returned, but before any saved state has been restored in to the View.</li>
339    <li>{@link android.app.Fragment#isDetached()} method determines whether
340    the Fragment has been explicitly detached from the UI.</li>
341    <li>New {@link android.app.FragmentTransaction#attach(android.app.Fragment) attach()}
342    and {@link android.app.FragmentTransaction#detach(android.app.Fragment) detach()}
343    methods let an application re-attach or detach fragments in the UI.</li>
344    <li>A new {@link android.app.FragmentTransaction#setCustomAnimations(int, int, int, int)
345    setCustomAnimations()} overload method lets you set specific animation
346    resources to run for enter/exit operations and specifically when
347    popping the back stack. The existing implementation does not account
348    for the different behavior of fragments when popping the back stack.</li>
349  </ul>
350</li>
351<li>Screen size information in ActivityInfo and ApplicationInfo
352  <ul>
353    <li>{@link android.content.pm.ActivityInfo} adds {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE}
354    and {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE} as bit masks
355    in {@link android.R.attr#configChanges}. The bits indicate whether an Activity can
356    itself handle the screen size and smallest screen size.</li>
357    <li>{@link android.content.pm.ApplicationInfo} adds
358    {@link android.content.pm.ApplicationInfo#largestWidthLimitDp}, {@link android.content.pm.ApplicationInfo#compatibleWidthLimitDp},
359    and {@link android.content.pm.ApplicationInfo#requiresSmallestWidthDp} fields,
360    derived from the corresponding <code>&lt;supports-screens&gt;</code> attributes
361    in the application manifest file.</li>
362  </ul>
363</li>
364<li>Helpers for getting display size from WindowManager
365  <ul>
366    <li>New methods {@link android.view.Display#getSize(android.graphics.Point)
367    getSize()} and {@link android.view.Display#getRectSize(android.graphics.Rect)
368    getRectSize()} let applications get the raw size of the display.</li>
369  </ul>
370</li>
371<li>New public "holographic" styles
372  <ul>
373    <li>The platform now exposes a variety of public "holographic" styles
374    for text, actionbar widgets and tabs, and more. See
375    {@link android.R.style} for a full list.</li>
376  </ul>
377</li>
378<li>{@link android.app.LocalActivityManager}, {@link android.app.ActivityGroup}, and
379    {@link android.app.LocalActivityManager} are now deprecated
380  <ul>
381    <li>New applications should use Fragments instead of these classes. To
382    continue to run on older versions of the platform, you can use the v4 Support
383    Library (compatibility library), available in the Android SDK. The v4 Support
384    Library provides a version of the Fragment API that is compatible down to
385    Android 1.6 (API level 4).
386    <li>For apps developing against Android 3.0 (API level
387    11) or higher, tabs are typically presented in the UI using the new
388    {@link android.app.ActionBar#newTab() ActionBar.newTab()} and related APIs
389    for placing tabs within their action bar area.</p></li>
390  </ul>
391</li>
392</ul>
393
394<h3 id="media" style="margin-top:1em;">Media framework</h3>
395<ul>
396    <li>Applications that use the platform's media provider ({@link
397    android.provider.MediaStore}) can now read media data directly from the
398    removeable SD card, where supported by the device. Applications can also
399    interact with the SD card files directly, using the MTP API. </li>
400
401</ul>
402<h3 id="graphics" style="margin-top:1.25em;">Graphics</h3>
403<ul>
404<li>Parcelable utilities in Point and PointF
405  <ul>
406    <li>{@link android.graphics.Point} and {@link android.graphics.PointF}
407    classes now include the {@link android.os.Parcelable} interface and utility methods {@link
408    android.graphics.Point#describeContents()}, {@link
409    android.graphics.Point#readFromParcel(android.os.Parcel) readFromParcel()}, and {@link
410    android.graphics.Point#writeToParcel(android.os.Parcel, int) writeToParcel()}.</li>
411  </ul>
412</li>
413</ul>
414
415
416<h3 id="ime" style="margin-top:1.25em;">IME framework</h3>
417<ul>
418    <li>New {@link android.view.KeyEvent#getModifiers()} method for
419    retrieving the current state of the modifier keys.</li>
420</ul>
421
422
423<h3 id="usb" style="margin-top:1.25em;">USB framework</h3>
424<ul>
425    <li>New {@link
426    android.hardware.usb.UsbDeviceConnection#getRawDescriptors()} method for
427    retrieving the raw USB descriptors for the device. You can use the
428    method to access descriptors not supported directly via the higher
429    level APIs.</li>
430</ul>
431
432
433<h3 id="network" style="margin-top:1.25em;">Network</h3>
434<ul>
435<li>Network type constants
436   <ul>
437     <li>{@link android.net.ConnectivityManager} adds the constants {@link
438     android.net.ConnectivityManager#TYPE_ETHERNET} and {@link
439     android.net.ConnectivityManager#TYPE_BLUETOOTH}.</li>
440  </ul>
441</li>
442</ul>
443
444
445<h3 id="telephony" style="margin-top:1.25em;">Telephony</h3>
446<ul>
447    <li>New {@link android.telephony.TelephonyManager#NETWORK_TYPE_HSPAP} network type constant.</li>
448</ul>
449
450<h3 id="other" style="margin-top:1.25em;">Core utilities</h3>
451<ul>
452<li>Parcelable utilities
453  <ul>
454    <li>New interface {@link android.os.Parcelable.ClassLoaderCreator} allows
455    the application to receive the ClassLoader in which the object is being created.</li>
456    <li>New {@link android.os.ParcelFileDescriptor#adoptFd(int) adoptFd}, {@link
457    android.os.ParcelFileDescriptor#dup(java.io.FileDescriptor) dup()}, and {@link
458    android.os.ParcelFileDescriptor#fromFd(int) fromFd()} for managing
459    {@link android.os.ParcelFileDescriptor} objects.</li>
460  </ul>
461</li>
462<li>Binder and IBinder
463  <ul>
464    <li>New method {@link android.os.Binder#dumpAsync(java.io.FileDescriptor, java.lang.String[]) dumpAsync()}
465    in {@link android.os.Binder} and {@link android.os.IBinder} let applications
466    dump to a specified file, ensuring that the target executes asynchronously.</li>
467    <li>New {@link android.os.IBinder} protocol transaction code {@link
468    android.os.IBinder#TWEET_TRANSACTION} lets applications send a tweet
469    to the target object.</li>
470  </ul>
471</li>
472</ul>
473
474
475
476
477<h3 id="features">New feature constants</h3>
478
479<p>The platform adds new hardware feature constants that you can declare
480in their application manifests, to inform external entities such as Google
481Play of required hardware and software capabilities. You declare these
482and other feature constants in <a
483href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code
484<uses-feature>}</a> manifest elements.
485
486<p>Google Play filters applications based on their <code>&lt;uses-feature&gt;</code> attributes, to ensure that they are available only to devices on which their requirements are met. </p>
487
488<ul>
489<li>Feature constants for landscape or portrait requirements
490
491<p>Android 3.2 introduces new feature constants that let applications specify whether they require display in landscape orientation, portrait orientation, or both. Declaring these constants indicates that the application must not be installed on a device that doesn't offer the associated orientation. Conversely, if one or both of the constants are not declared, it indicates that the application does not have a preference for the undeclared orientations and may be installed on a device that doesn't offer them. </p>
492
493<ul>
494  <li>{@link android.content.pm.PackageManager#FEATURE_SCREEN_LANDSCAPE
495android.hardware.screen.landscape} &mdash; The application requires display in
496landscape orientation.</li>
497  <li>{@link android.content.pm.PackageManager#FEATURE_SCREEN_PORTRAIT
498android.hardware.screen.portrait} &mdash; The application requires display in
499portrait orientation.</li>
500</ul>
501
502<p>A typical application that functions properly in both landscape and portrait orientations would not normally need to declare an orientation requirement. Rather, an application designed primarily for one orientation, such as an app designed for a television, could declare one of the constants to ensure that it isn't available to devices that don't provide that orientation.</p>
503
504<p>If any of activities declared in the manifest request that they run in a specific orientation,
505using the <a href="{@docRoot}guide/topics/manifest/activity-element.html#screen">{@code
506android:screenOrientation}</a> attribute, then this also declares that the application
507requires that orientation.</p>
508
509</li>
510<li>Other feature constants
511
512<ul>
513  <li>{@link android.content.pm.PackageManager#FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT
514android.hardware.faketouch.multitouch.distinct} &mdash; The application requires support for emulated mulitouch input with distinct tracking of two or more points.</li>
515
516  <li>{@link android.content.pm.PackageManager#FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND
517android.hardware.faketouch.multitouch.jazzhand} &mdash; The application requires support for emulated mulitouch input with distinct tracking of five or more points.</li>
518</ul>
519
520</li>
521</ul>
522
523
524<h3 id="api-diff">API Differences Report</h3>
525
526<p>For a detailed view of all API changes in Android {@sdkPlatformVersion} (API
527Level
528{@sdkPlatformApiLevel}), see the <a
529href="{@docRoot}sdk/api_diff/{@sdkPlatformApiLevel}/changes.html">API
530Differences Report</a>.</p>
531
532
533
534
535
536<h2 id="api-level">API Level</h2>
537
538<p>The Android {@sdkPlatformVersion} platform delivers an updated version of
539the framework API. The Android {@sdkPlatformVersion} API
540is assigned an integer identifier &mdash;
541<strong>{@sdkPlatformApiLevel}</strong> &mdash; that is
542stored in the system itself. This identifier, called the "API Level", allows the
543system to correctly determine whether an application is compatible with
544the system, prior to installing the application. </p>
545
546<p>To use APIs introduced in Android {@sdkPlatformVersion} in your application,
547you need compile the application against the Android library that is provided in
548the Android {@sdkPlatformVersion} SDK platform. Depending on your needs, you
549might
550also need to add an <code>android:minSdkVersion="{@sdkPlatformApiLevel}"</code>
551attribute to the <code>&lt;uses-sdk&gt;</code> element in the application's
552manifest.</p>
553
554<p>For more information, read <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">What is API
555Level?</a></p>
556
557
558