• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=Android 3.0 Platform
2sdk.platform.version=3.0
3sdk.platform.apiLevel=11
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="#api">API Overview</a></li>
12  <li><a href="#api-level">API Level</a></li>
13</ol>
14
15<h2>Reference</h2>
16<ol>
17<li><a
18href="{@docRoot}sdk/api_diff/11/changes.html">API
19Differences Report &raquo;</a> </li>
20</ol>
21
22</div>
23</div>
24
25
26<p><em>API Level:</em>&nbsp;<strong>{@sdkPlatformApiLevel}</strong></p>
27
28<p>For developers, the Android {@sdkPlatformVersion} platform is available as a downloadable
29component for the Android SDK. The downloadable platform includes an Android library and system
30image, as well as a set of emulator skins and more. The downloadable platform includes no external
31libraries.</p>
32
33<p>For developers, the Android {@sdkPlatformVersion} platform is available as a
34downloadable component for the Android SDK. The downloadable platform includes
35an Android library and system image, as well as a set of emulator skins and
36more. To get started developing or testing against Android {@sdkPlatformVersion},
37use the Android SDK Manager to download the platform into your SDK.</p>
38
39
40
41
42
43
44<h2 id="#api">API Overview</h2>
45
46<p>The sections below provide a technical overview of what's new for developers in Android 3.0,
47including new features and changes in the framework API since the previous version.</p>
48
49
50
51
52
53<h3>Fragments</h3>
54
55<p>A fragment is a new framework component that allows you to separate distinct elements of an
56activity into self-contained modules that define their own UI and lifecycle. To create a
57fragment, you must extend the {@link android.app.Fragment} class and implement several lifecycle
58callback methods, similar to an {@link android.app.Activity}. You can then combine multiple
59fragments in a single activity to build a multi-pane UI in which each
60pane manages its own lifecycle and user inputs.</p>
61
62<p>You can also use a fragment without providing a UI and instead use the fragment as a worker
63for the activity, such as to manage the progress of a download that occurs only while the
64activity is running.</p>
65
66<p>Additionally:</p>
67
68<ul>
69  <li>Fragments are self-contained and you can reuse them in multiple activities</li>
70  <li>You can add, remove, replace and animate fragments inside the activity</li>
71  <li>You can add fragments to a back stack managed by the activity, preserving the state of
72fragments as they are changed and allowing the user to navigate backward through the different
73states</li>
74  <li>By <a
75href="{@docRoot}guide/topics/resources/providing-resources.html#AlternativeResources">providing
76alternative layouts</a>, you can mix and match fragments, based
77on the screen size and orientation</li>
78  <li>Fragments have direct access to their container activity and can contribute items to the
79activity's Action Bar (discussed next)</li>
80</ul>
81
82<p>To manage the fragments in your activity, you must use the {@link
83android.app.FragmentManager}, which provides several APIs for interacting with fragments, such
84as finding fragments in the activity and popping fragments off the back stack to restore their
85previous state.</p>
86
87<p>To perform a transaction, such as add or remove a fragment, you must create a {@link
88android.app.FragmentTransaction}. You can then call methods such as {@link
89android.app.FragmentTransaction#add add()} {@link android.app.FragmentTransaction#remove
90remove()}, or {@link android.app.FragmentTransaction#replace replace()}. Once you've applied all
91the changes you want to perform for the transaction, you must call {@link
92android.app.FragmentTransaction#commit commit()} and the system applies the fragment transaction to
93the activity.</p>
94
95<p>For more information about using fragments, read the <a
96href="{@docRoot}guide/components/fragments.html">Fragments</a> documentation. Several
97samples are also available in the <a
98href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/index.html#Fragment">
99API Demos</a> application.</p>
100
101
102
103
104<h3>Action Bar</h3>
105
106<p>The Action Bar is a replacement for the traditional title bar at the top of the activity window.
107It includes the application logo in the left corner and provides a new interface for items in the
108<a href="{@docRoot}guide/topics/ui/menus.html#options-menu">Options Menu</a>. Additionally, the
109Action Bar allows you to:</p>
110
111<ul>
112  <li>Add menu items directly in the Action Bar&mdash;as "action items."
113    <p>In your XML declaration for the menu item, include the {@code
114android:showAsAction} attribute with a value of {@code "ifRoom"}. When there's enough room, the menu
115item appears directly in the Action Bar. Otherwise, the item is placed in the
116overflow menu, revealed by the menu icon on the right side of the Action Bar.</p></li>
117
118  <li>Replace an action item with a widget (such as a search box)&mdash;creating an
119"action view."
120    <p>In the XML declaration for the menu item, add the {@code android:actionViewLayout} attribute
121with a layout resource or the {@code android:actionViewClass} attribute with the class name of a
122widget. (You must also declare the {@code android:showAsAction} attribute so that the item appears
123in the Action Bar.) If there's not enough room in the Action Bar and the item appears in the
124overflow menu, it behaves like a regular menu item and does not show the widget.</p></li>
125
126  <li>Add an action to the application logo and replace it with a custom logo
127    <p>The application logo is automatically assigned the {@code android.R.id.home} ID,
128which the system delivers to your activity's {@link android.app.Activity#onOptionsItemSelected
129onOptionsItemSelected()} callback when touched. Simply respond to this ID in your callback
130method to perform an action such as go to your application's "home" activity.</p>
131    <p>To replace the icon with a logo, specify your application logo in the manifest file with the
132<a href="{@docRoot}guide/topics/manifest/application-element.html#logo">{@code android:logo}</a>
133attribute, then call {@link android.app.ActionBar#setDisplayUseLogoEnabled
134setDisplayUseLogoEnabled(true)} in your activity.</p></li>
135
136  <li>Add breadcrumbs to navigate backward through the back stack of fragments</li>
137  <li>Add tabs or a drop-down list to navigate through fragments</li>
138  <li>Customize the Action Bar with themes and backgrounds</li>
139</ul>
140
141<p>The Action Bar is standard for all applications that use the new holographic theme, which is
142also standard when you set either the <a
143href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
144android:minSdkVersion}</a> or <a
145href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
146android:targetSdkVersion}</a> to {@code "11"}.</p>
147
148<p>For more information about the Action Bar, read the <a
149href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> documentation. Several
150samples are also available in the <a
151href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/index.html#ActionBar">
152API Demos</a> application.</p>
153
154
155
156
157<h3>System clipboard</h3>
158
159<p>Applications can now copy and paste data (beyond mere text) to and from the system-wide
160clipboard. Clipped data can be plain text, a URI, or an intent.</p>
161
162<p>By providing the system access to the data you want the user to copy, through a content provider,
163the user can copy complex content (such as an image or data structure) from your application and
164paste it into another application that supports that type of content.</p>
165
166<p>To start using the clipboard, get the global {@link android.content.ClipboardManager} object
167by calling {@link android.content.Context#getSystemService getSystemService(CLIPBOARD_SERVICE)}.</p>
168
169<p>To copy an item to the clipboard, you need to create a new {@link
170android.content.ClipData} object, which holds one or more {@link android.content.ClipData.Item}
171objects, each describing a single entity. To create a {@link android.content.ClipData} object
172containing just one {@link android.content.ClipData.Item}, you can use one of the helper methods,
173such as {@link android.content.ClipData#newPlainText newPlainText()}, {@link
174android.content.ClipData#newUri newUri()}, and {@link android.content.ClipData#newIntent
175newIntent()}, which each return a {@link android.content.ClipData} object pre-loaded with the
176{@link android.content.ClipData.Item} you provide.</p>
177
178<p>To add the {@link android.content.ClipData} to the clipboard, pass it to {@link
179android.content.ClipboardManager#setPrimaryClip setPrimaryClip()} for your instance of {@link
180android.content.ClipboardManager}.</p>
181
182<p>You can then read a file from the clipboard (in order to paste it) by calling {@link
183android.content.ClipboardManager#getPrimaryClip()} on the {@link
184android.content.ClipboardManager}. Handling the {@link android.content.ClipData} you receive can
185be complicated and you need to be sure you can actually handle the data type in the clipboard
186before attempting to paste it.</p>
187
188<p>The clipboard holds only one piece of clipped data (a {@link android.content.ClipData}
189object) at a time, but one {@link android.content.ClipData} can contain multiple {@link
190android.content.ClipData.Item}s.</p>
191
192<p>For more information, read the <a href="{@docRoot}guide/topics/text/copy-paste.html">Copy
193and Paste</a> documentation. You can also see a simple implementation of copy and paste in the API Demos
194sample and a more complete implementation in the Note Pad sample.</p>
195
196
197
198
199<h3>Drag and drop</h3>
200
201<p>New APIs simplify drag and drop operations in your application's user interface. A drag
202operation is the transfer of some kind of data&mdash;carried in a {@link android.content.ClipData}
203object&mdash;from one place to another. The start and end point for the drag operation is a {@link
204android.view.View}, so the APIs that directly handle the drag and drop operations are
205in the {@link android.view.View} class.</p>
206
207<p>A drag and drop operation has a lifecycle that's defined by several drag actions&mdash;each
208defined by a {@link android.view.DragEvent} object&mdash;such as {@link
209android.view.DragEvent#ACTION_DRAG_STARTED}, {@link android.view.DragEvent#ACTION_DRAG_ENTERED}, and
210{@link android.view.DragEvent#ACTION_DROP}. Each view that wants to participate in a drag
211operation can listen for these actions.</p>
212
213<p>To begin dragging content in your activity, call {@link android.view.View#startDrag startDrag()}
214on a {@link android.view.View}, providing a {@link android.content.ClipData} object that represents
215the data to drag, a {@link android.view.View.DragShadowBuilder} to facilitate the "shadow"
216that users see under their fingers while dragging, and an {@link java.lang.Object} that can share
217information about the drag object with views that may receive the object.</p>
218
219<p>To accept a drag object in a {@link android.view.View} (receive the "drop"), register the view
220with an {@link android.view.View.OnDragListener OnDragListener} by calling {@link
221android.view.View#setOnDragListener setOnDragListener()}. When a drag event occurs on the view, the
222system calls {@link android.view.View.OnDragListener#onDrag onDrag()} for the  {@link
223android.view.View.OnDragListener OnDragListener}, which receives a {@link android.view.DragEvent}
224describing the type of drag action has occurred (such as {@link
225android.view.DragEvent#ACTION_DRAG_STARTED}, {@link android.view.DragEvent#ACTION_DRAG_ENTERED}, and
226{@link android.view.DragEvent#ACTION_DROP}). During a drag, the system repeatedly calls {@link
227android.view.View.OnDragListener#onDrag onDrag()} for the view underneath the drag, to deliver a
228stream of drag events. The receiving view can inquire the event type delivered to {@link
229android.view.View#onDragEvent onDragEvent()} by calling {@link android.view.DragEvent#getAction
230getAction()} on the {@link android.view.DragEvent}.</p>
231
232<p class="note"><strong>Note:</strong> Although a drag event may carry a {@link
233android.content.ClipData} object, this is not related to the system clipboard. A drag and drop
234operation should never put the dragged data in the system clipboard.</p>
235
236<p>For more information, read the <a href="{@docRoot}guide/topics/ui/drag-drop.html">Dragging and
237Dropping</a> documentation. You can also see an implementation of drag and drop in the <a
238href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/DragAndDropDemo.html">
239API Demos</a> application and the <a
240href="{@docRoot}resources/samples/HoneycombGallery/index.html">Honeycomb Gallery</a>
241application.</p>
242
243
244
245<h3>App widgets</h3>
246
247<p>Android 3.0 supports several new widget classes for more interactive app widgets on the users
248Home screen, including: {@link android.widget.GridView}, {@link android.widget.ListView}, {@link
249android.widget.StackView}, {@link android.widget.ViewFlipper}, and {@link
250android.widget.AdapterViewFlipper}.</p>
251
252<p>More importantly, you can use the new {@link android.widget.RemoteViewsService} to create app
253widgets with collections, using widgets such as {@link android.widget.GridView}, {@link
254android.widget.ListView}, and {@link android.widget.StackView} that are backed by remote data,
255such as from a content provider.</p>
256
257<p>The {@link android.appwidget.AppWidgetProviderInfo} class (defined in XML with an {@code
258&lt;appwidget-provider&gt;} element) also supports two new fields: {@link
259android.appwidget.AppWidgetProviderInfo#autoAdvanceViewId} and {@link
260android.appwidget.AppWidgetProviderInfo#previewImage}. The {@link
261android.appwidget.AppWidgetProviderInfo#autoAdvanceViewId} field lets you specify the view ID of the
262app widget subview that should be auto-advanced by the app widget’s host. The
263{@link android.appwidget.AppWidgetProviderInfo#previewImage} field specifies a preview of what the
264app widget looks like and is shown to the user from the widget picker. If this field is not
265supplied, the app widget's icon is used for the preview.</p>
266
267<p>To help create a preview image for your app widget (to specify in the {@link
268android.appwidget.AppWidgetProviderInfo#previewImage} field), the Android emulator includes an
269application called "Widget Preview." To create a preview image, launch this application, select the
270app widget for your application and set it up how you'd like your preview image to appear, then save
271it and place it in your application's drawable resources.</p>
272
273<p>You can see an implementation of the new app widget features in the <a
274href="{@docRoot}resources/samples/StackWidget/index.html">StackView App Widget</a> and <a
275href="{@docRoot}resources/samples/WeatherListWidget/index.html">Weather List Widget</a>
276applications.</p>
277
278
279
280<h3>Status bar notifications</h3>
281
282<p>The {@link android.app.Notification} APIs have been extended to support more content-rich status
283bar notifications, plus a new {@link android.app.Notification.Builder} class allows you to easily
284create {@link android.app.Notification} objects.</p>
285<p>New features include:</p>
286<ul>
287  <li>Support for a large icon in the notification, using {@link
288android.app.Notification.Builder#setLargeIcon setLargeIcon()}. This is usually for
289social applications to show the contact photo of the person who is the source of the
290notification or for media apps to show an album thumbnail.</li>
291  <li>Support for custom layouts in the status bar ticker, using {@link
292android.app.Notification.Builder#setTicker(CharSequence,RemoteViews) setTicker()}.</li>
293  <li>Support for custom notification layouts to include buttons with {@link
294android.app.PendingIntent}s, for more interactive notification widgets. For example, a
295notification can control music playback without starting an activity.</li>
296</ul>
297
298
299
300<h3>Content loaders</h3>
301
302<p>New framework APIs facilitate asynchronous loading of data using the {@link
303android.content.Loader} class. You can use it in combination with UI components such as views and
304fragments to dynamically load data from worker threads. The {@link
305android.content.CursorLoader} subclass is specially designed to help you do so for data backed by
306a {@link android.content.ContentProvider}.</p>
307
308<p>All you need to do is implement the {@link android.app.LoaderManager.LoaderCallbacks
309LoaderCallbacks} interface to receive callbacks when a new loader is requested or the data has
310changed, then call {@link android.app.LoaderManager#initLoader initLoader()} to initialize the
311loader for your activity or fragment.</p>
312
313<p>For more information, read the <a
314href="{@docRoot}guide/components/loaders.html">Loaders</a> documentation. You can also see
315example code using loaders in the <a
316href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.html">LoaderCursor</a>
317and <a
318href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.html">
319LoaderThrottle</a> samples.</p>
320
321
322
323<h3>Bluetooth A2DP and headset APIs</h3>
324
325<p>Android now includes APIs for applications to verify the state of connected Bluetooth A2DP and
326headset profile devices. For example, applications can identify when a Bluetooth headset is
327connected for listening to music and notify the user as appropriate. Applications can also receive
328broadcasts for vendor specific AT commands and notify the user about the state of the connected
329device, such as when the connected device's battery is low.</p>
330
331<p>You can initialize the respective {@link android.bluetooth.BluetoothProfile} by calling {@link
332android.bluetooth.BluetoothAdapter#getProfileProxy getProfileProxy()} with either the {@link
333android.bluetooth.BluetoothProfile#A2DP} or {@link android.bluetooth.BluetoothProfile#HEADSET}
334profile constant and a {@link android.bluetooth.BluetoothProfile.ServiceListener} to receive
335callbacks when the Bluetooth client is connected or disconnected.</p>
336
337
338
339
340<h3 id="animation">Animation framework</h3>
341
342<p>An all new flexible animation framework allows you to animate arbitrary properties of any object
343(View, Drawable, Fragment, Object, or anything else). It allows you to define several aspects of an
344animation, such as:</p>
345<ul>
346  <li>Duration</li>
347  <li>Repeat amount and behavior</li>
348  <li>Type of time interpolation</li>
349  <li>Animator sets to play animations together, sequentially, or after specified delays</li>
350  <li>Frame refresh delay</li>
351</ul>
352
353 <p>You can define these animation aspects, and others, for an object's int, float, and hexadecimal
354color values, by default. That is, when an object has a property field for one of these types, you
355can change its value over time to affect an animation. To animate any other type of value, you tell
356the system how to calculate the values for that given type, by implementing the {@link
357android.animation.TypeEvaluator} interface.</p>
358
359<p>There are two animators you can use to animate the values of a property: {@link
360android.animation.ValueAnimator} and {@link android.animation.ObjectAnimator}. The {@link
361android.animation.ValueAnimator} computes the animation values, but is not aware of the specific
362object or property that is animated as a result. It simply performs the calculations, and you must
363listen for the updates and process the data with your own logic. The {@link
364android.animation.ObjectAnimator} is a subclass of {@link android.animation.ValueAnimator} and
365allows you to set the object and property to animate, and it handles all animation work.
366That is, you give the {@link android.animation.ObjectAnimator} the object to animate, the
367property of the object to change over time, and a set of values to apply to the property over
368time, then start the animation.</p>
369
370<p>Additionally, the {@link android.animation.LayoutTransition} class enables automatic transition
371animations for changes you make to your activity layout. To enable transitions for part of the
372layout, create a {@link android.animation.LayoutTransition} object and set it on
373any {@link android.view.ViewGroup} by calling {@link
374android.view.ViewGroup#setLayoutTransition setLayoutTransition()}. This causes default
375animations to run whenever items are added to or removed from the group. To specify custom
376animations, call {@link android.animation.LayoutTransition#setAnimator setAnimator()} on the {@link
377android.animation.LayoutTransition} and provide a custom {@link android.animation.Animator},
378such as a {@link android.animation.ValueAnimator} or {@link android.animation.ObjectAnimator}
379discussed above.</p>
380
381<p>For more information, see the <a
382href="{@docRoot}guide/topics/graphics/prop-animation.html">Property Animation</a> documentation. You can
383also see several samples using the animation APIs in the <a
384href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/animation/index.html">API
385Demos</a> application.</p>
386
387
388
389
390<h3>Extended UI framework</h3>
391
392<ul>
393
394  <li><b>Multiple-choice selection for ListView and GridView</b>
395
396<p>New {@link android.widget.AbsListView#CHOICE_MODE_MULTIPLE_MODAL} mode for {@link
397android.widget.AbsListView#setChoiceMode setChoiceMode()} allows users to select multiple items
398from a {@link android.widget.ListView} or {@link android.widget.GridView}. When used in
399conjunction with the Action Bar, users can select multiple items and then select the action to
400perform from a list of options in the Action Bar (which has transformed into a Multi-choice
401Action Mode).</p>
402
403<p>To enable multiple-choice selection, call {@link
404android.widget.AbsListView#setChoiceMode setChoiceMode(CHOICE_MODE_MULTIPLE_MODAL)} and register a
405{@link android.widget.AbsListView.MultiChoiceModeListener MultiChoiceModeListener} with {@link
406android.widget.AbsListView#setMultiChoiceModeListener setMultiChoiceModeListener()}.</p>
407
408<p>When the user performs a long-press on an item, the Action Bar switches to the Multi-choice
409Action Mode. The system notifies the {@link android.widget.AbsListView.MultiChoiceModeListener
410MultiChoiceModeListener} when items are selected by calling {@link
411android.widget.AbsListView.MultiChoiceModeListener#onItemCheckedStateChanged
412onItemCheckedStateChanged()}.</p>
413
414<p>For an example of multiple-choice selection, see the <a
415href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/List15.html">List15.
416java</a>
417class in the API Demos sample application.</p>
418  </li>
419
420
421  <li><b>New APIs to transform views</b>
422
423    <p>New APIs allow you to easily apply 2D and 3D transformations to views in your activity
424layout. New transformations are made possible with a set of object properties that define the view's
425layout position, orientation, transparency and more.</p>
426    <p>New methods to set the view properties include: {@link android.view.View#setAlpha
427setAlpha()}, {@link
428android.view.View#setBottom setBottom()}, {@link android.view.View#setLeft setLeft()}, {@link
429android.view.View#setRight setRight()}, {@link android.view.View#setBottom setBottom()}, {@link
430android.view.View#setPivotX setPivotX()}, {@link android.view.View#setPivotY setPivotY()}, {@link
431android.view.View#setRotationX setRotationX()}, {@link android.view.View#setRotationY
432setRotationY()}, {@link android.view.View#setScaleX setScaleX()}, {@link android.view.View#setScaleY
433setScaleY()}, {@link android.view.View#setAlpha setAlpha()}, and others.</p>
434
435    <p>Some methods also have a corresponding XML attribute that you can specify in your layout
436file, to apply a default transformation. Available attributes include: {@code translationX}, {@code
437translationY}, {@code rotation},
438{@code rotationX}, {@code rotationY}, {@code scaleX}, {@code scaleY}, {@code transformPivotX},
439{@code transformPivotY}, and {@code alpha}.</p>
440
441    <p>Using some of these new view properties in combination with the new <a
442href="#animation">animation framework</a> (discussed
443above), you can easily apply some fancy animations to your views. For example, to rotate a
444view on its y-axis, supply {@link android.animation.ObjectAnimator} with the {@link
445android.view.View}, the "rotationY" property, and the start and end values:</p>
446<pre>
447ObjectAnimator animator = ObjectAnimator.ofFloat(myView, "rotationY", 0, 360);
448animator.setDuration(2000);
449animator.start();
450</pre>
451  </li>
452
453
454  <li><b>New holographic themes</b>
455
456    <p>The standard system widgets and overall look have been redesigned and incorporate a new
457"holographic" user interface theme. The system applies the new theme
458using the standard <a href="{@docRoot}guide/topics/ui/themes.html">style and theme</a> system.</p>
459
460<p>Any application that targets the Android 3.0 platform&mdash;by setting either the <a
461href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>
462or <a
463href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
464android:targetSdkVersion}</a> value to {@code "11"}&mdash;inherits the holographic theme by default.
465However, if your application also applies its own theme, then your theme will override the
466holographic theme, unless you update your styles to inherit the holographic theme.</p>
467
468<p>To apply the holographic theme to individual activities or to inherit them in your own theme
469definitions, use one of several new {@link android.R.style#Theme_Holo Theme.Holo}
470themes. If your application is compatible with version of Android lower than 3.0 and applies
471custom themes, then you should <a
472href="{@docRoot}guide/topics/ui/themes.html#SelectATheme">select a theme based on platform
473version</a>.</p>
474
475  </li>
476
477
478  <li><b>New widgets</b>
479
480    <ul>
481    <li>{@link android.widget.AdapterViewAnimator}
482    <p>Base class for an {@link android.widget.AdapterView} that performs animations when switching
483    between its views.</p></li>
484
485    <li>{@link android.widget.AdapterViewFlipper}
486    <p>Simple {@link android.widget.ViewAnimator} that animates between two or more views that have
487    been added to it. Only one child is shown at a time. If requested, it can automatically flip
488  between
489    each child at a regular interval.</p></li>
490
491    <li>{@link android.widget.CalendarView}
492    <p>Allows users to select dates from a calendar by touching the date and can scroll or fling the
493calendar to a desired date. You can configure the range of dates available in the widget.</p></li>
494
495    <li>{@link android.widget.ListPopupWindow}
496    <p>Anchors itself to a host view and displays a list of choices, such as for a list of
497    suggestions when typing into an {@link android.widget.EditText} view.</p></li>
498
499    <li>{@link android.widget.NumberPicker}
500    <p>Enables the user to select a number from a predefined range. The widget presents an input
501field and up and down buttons for selecting a number. Touching the input field allows the user to
502scroll through values or touch again to directly edit the current value. It also allows you to map
503positions to strings, so that the corresponding string is displayed instead of the index
504position.</p></li>
505
506    <li>{@link android.widget.PopupMenu}
507    <p>Displays a {@link android.view.Menu} in a modal popup window that's anchored to a view. The
508popup appears below the anchor view if there is room, or above it if there is not. If the IME (soft
509keyboard) is visible, the popup does not overlap the IME it until the user touches the
510menu.</p></li>
511
512    <li>{@link android.widget.SearchView}
513    <p>Provides a search box that you can configure to deliver search queries to a specified
514activity and display search suggestions (in the same manner as the traditional search dialog). This
515widget is particularly useful for offering a search widget in the Action Bar. For more information,
516see <a href="{@docRoot}guide/topics/search/search-dialog.html">Creating a Search Interface.</p></li>
517
518    <li>{@link android.widget.StackView}
519    <p>A view that displays its children in a 3D stack and allows users to swipe through
520  views like a rolodex.</p></li>
521
522    </ul>
523  </li>
524
525</ul>
526
527
528
529<h3>Graphics</h3>
530
531<ul>
532  <li><b>Hardware accelerated 2D graphics</b>
533
534<p>You can now enable the OpenGL renderer for your application by setting {@code
535android:hardwareAccelerated="true"} in your manifest element's <a
536href="{@docRoot}guide/topics/manifest/application-element.html">{@code &lt;application&gt;}</a>
537element or for individual <a
538href="{@docRoot}guide/topics/manifest/activity-element.html">{@code &lt;activity&gt;}</a>
539elements.</p>
540
541<p>This flag helps applications by making them draw faster. This results in smoother animations,
542smoother scrolling, and overall better performance and response to user interaction.</p></li>
543
544
545  <li><b>View support for hardware and software layers</b>
546
547    <p>By default, a {@link android.view.View} has no layer specified. You can specify that the
548view be backed by either a hardware or software layer, specified by values {@link
549android.view.View#LAYER_TYPE_HARDWARE} and {@link android.view.View#LAYER_TYPE_SOFTWARE}, using
550{@link android.view.View#setLayerType setLayerType()} or the <a
551href="{@docRoot}reference/android/view/View.html#attr_android:layerType">{@code layerType}</a>
552attribute.</p>
553    <p>A hardware layer is backed by a hardware specific texture (generally Frame Buffer Objects or
554FBO on OpenGL hardware) and causes the view to be rendered using Android's hardware rendering
555pipeline, but only if hardware acceleration is turned on for the view hierarchy. When hardware
556acceleration is turned off, hardware layers behave exactly as software layers.</p>
557    <p>A software layer is backed by a bitmap and causes the view to be rendered using Android's
558software rendering pipeline, even if hardware acceleration is enabled. Software layers should be
559avoided when the affected view tree updates often. Every update will require to re-render the
560software layer, which can potentially be slow.</p>
561    <p>For more information, see the {@link android.view.View#LAYER_TYPE_HARDWARE} and {@link
562android.view.View#LAYER_TYPE_SOFTWARE} documentation.</p>
563  </li>
564
565
566  <li><b>Renderscript 3D graphics engine</b>
567
568<p>Renderscript is a runtime 3D framework that provides both an API for building 3D scenes as well
569as a special, platform-independent shader language for maximum performance. Using Renderscript, you
570can accelerate graphics operations and data processing. Renderscript is an ideal way to create
571high-performance 3D effects for applications, wallpapers, carousels, and more.</p>
572<p>For more information, see the <a
573href="{@docRoot}guide/topics/graphics/renderscript.html">3D Rendering and Computation with
574Renderscript</a> documentation.</p></li>
575</ul>
576
577
578
579
580<h3>Media</h3>
581
582
583<ul>
584
585  <li><b>Time lapse video</b>
586
587<p>Camcorder APIs now support the ability to record time lapse video. The {@link
588android.media.MediaRecorder#setCaptureRate setCaptureRate()} sets the rate at which frames
589should be captured.</p></li>
590
591  <li><b>Texture support for image streams</b>
592
593<p>New {@link android.graphics.SurfaceTexture} allows you to capture an image stream as an OpenGL ES
594texture. By calling {@link android.hardware.Camera#setPreviewTexture setPreviewTexture()} for your
595{@link android.hardware.Camera} instance, you can specify the {@link
596android.graphics.SurfaceTexture} upon which to draw video playback or preview frames from the
597camera.</p></li>
598
599  <li><b>HTTP Live streaming</b>
600
601<p>Applications can now pass an M3U playlist URL to the media framework to begin an HTTP Live
602streaming session. The media framework supports most of the HTTP Live streaming specification,
603including adaptive bit rate. See the <a
604href="{@docRoot}guide/appendix/media-formats.html">Supported Media Formats</a> document for
605more information.</p></li>
606
607  <li><b>EXIF data</b>
608
609<p>The {@link android.media.ExifInterface} includes new fields for photo aperture, ISO, and exposure
610time.</p></li>
611
612  <li><b>Camcorder profiles</b>
613
614<p>New {@link android.media.CamcorderProfile#hasProfile hasProfile()} method and several video
615quality profiles (such as {@link android.media.CamcorderProfile#QUALITY_1080P}, {@link
616android.media.CamcorderProfile#QUALITY_720P}, {@link
617android.media.CamcorderProfile#QUALITY_CIF}, and others) allow you to determine camcorder
618quality options.</p></li>
619
620  <li><b>Digital media file transfer</b>
621
622<p>The platform includes built-in support for Media/Picture Transfer Protocol (MTP/PTP) over USB,
623which lets users easily transfer any type of media files between devices and to a host computer.
624Developers can build on this support, creating applications that let users create or manage rich
625media files that they may want to transfer or share across devices. </p></li>
626
627  <li><b>Digital rights management (DRM)</b>
628
629<p>New extensible digital rights management (DRM) framework for checking and enforcing digital
630rights. It's implemented in two architectural layers:</p>
631<ul>
632  <li>A DRM framework API, which is exposed to applications and runs through the Dalvik VM for
633standard applications.</li>
634  <li>A native code DRM manager that implements the framework API and exposes an interface for DRM
635plug-ins to handle rights management and decryption for various DRM schemes.</li>
636</ul>
637
638<p>For application developers, the framework offers an abstract, unified API that simplifies the
639management of protected content. The API hides the complexity of DRM operations and allows a
640consistent operation mode for both protected and unprotected content, and across a variety of DRM
641schemes.</p>
642
643<p>For device manufacturers, content owners, and Internet digital media providers the DRM
644framework?s plugin API provides a means of adding support for a DRM scheme of choice into the
645Android system, for secure enforcement of content protection.</p>
646
647<p>The preview release does not provide any native DRM plug-ins for checking and enforcing digital
648rights. However, device manufacturers may ship DRM plug-ins with their devices.</p>
649
650<p>You can find all of the DRM APIs in the {@link android.drm} package.</p></li>
651
652</ul>
653
654
655
656<h3>Keyboard support</h3>
657
658<ul>
659<li>Support for Control, Meta, Caps Lock, Num Lock and Scroll Lock modifiers. For more information,
660see {@link android.view.KeyEvent#META_CTRL_ON} and related fields.</li>
661
662<li>Support for full desktop-style keyboards, including support for keys such as Escape, Home, End,
663Delete and others. You can determine whether key events are coming from a full keyboard by
664querying {@link android.view.KeyCharacterMap#getKeyboardType()} and checking for {@link
665android.view.KeyCharacterMap#FULL KeyCharacterMap.FULL}</li>
666
667<li>{@link android.widget.TextView} now supports keyboard-based cut, copy, paste, and select-all,
668using the key combinations Ctrl+X, Ctrl+C, Ctrl+V, and Ctrl+A.  It also supports PageUp/PageDown,
669Home/End, and keyboard-based text selection.</li>
670
671<li>{@link android.view.KeyEvent} adds several new methods to make it easier to check the key
672modifier state correctly and consistently. See {@link android.view.KeyEvent#hasModifiers(int)},
673{@link android.view.KeyEvent#hasNoModifiers()},
674{@link android.view.KeyEvent#metaStateHasModifiers(int,int) metaStateHasModifiers()},
675{@link android.view.KeyEvent#metaStateHasNoModifiers(int) metaStateHasNoModifiers()}.</li>
676
677<li>Applications can implement custom keyboard shortcuts by subclassing {@link
678android.app.Activity}, {@link android.app.Dialog}, or {@link android.view.View} and implementing
679{@link android.app.Activity#onKeyShortcut onKeyShortcut()}.  The framework calls this method
680whenever a key is combined with Ctrl key.  When creating an <a
681href="{@docRoot}guide/topics/ui/menus.html#options-menu">Options Menu</a>, you can register keyboard
682shortcuts by setting either the {@code android:alphabeticShortcut} or {@code
683android:numericShortcut} attribute for each <a
684href="{@docRoot}guide/topics/resources/menu-resource.html#item-element">{@code &lt;item&gt;}</a>
685element (or with {@link android.view.MenuItem#setShortcut setShortcut()}).</li>
686
687<li>Android 3.0 includes a new "virtual keyboard" device with the id {@link
688android.view.KeyCharacterMap#VIRTUAL_KEYBOARD KeyCharacterMap.VIRTUAL_KEYBOARD}. The virtual
689keyboard has a desktop-style US key map which is useful for synthesizing key events for testing
690input.</li>
691
692</ul>
693
694
695
696
697<h3>Split touch events</h3>
698
699<p>Previously, only a single view could accept touch events at one time. Android 3.0
700adds support for splitting touch events across views and even windows, so different views can accept
701simultaneous touch events.</p>
702
703<p>Split touch events is enabled by default when an application targets
704Android 3.0. That is, when the application has set either the <a
705href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>
706or <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
707android:targetSdkVersion}</a> attribute's value to {@code "11"}.</p>
708
709<p>However, the following properties allow you to disable split touch events across views inside
710specific view groups and across windows.</p>
711
712<ul>
713<li>The {@link android.R.attr#splitMotionEvents android:splitMotionEvents} attribute for view groups
714allows you to disable split touch events that occur between child views in a layout. For example:
715<pre>
716&lt;LinearLayout android:splitMotionEvents="false" ... >
717    ...
718&lt;/LinearLayout>
719</pre>
720<p>This way, child views in the linear layout cannot split touch events&mdash;only one view can
721receive touch events at a time.</p>
722</li>
723
724<li>The {@link android.R.attr#windowEnableSplitTouch android:windowEnableSplitTouch} style property
725allows you to disable split touch events across windows, by applying it to a theme for the activity
726or entire application. For example:
727<pre>
728&lt;style name="NoSplitMotionEvents" parent="android:Theme.Holo">
729    &lt;item name="android:windowEnableSplitTouch">false&lt;/item>
730    ...
731&lt;/style>
732</pre>
733<p>When this theme is applied to an <a
734href="{@docRoot}guide/topics/manifest/activity-element.html">{@code &lt;activity&gt;}</a> or <a
735href="{@docRoot}guide/topics/manifest/application-element.html">{@code &lt;application&gt;}</a>,
736only touch events within the current activity window are accepted. For example, by disabling split
737touch events across windows, the system bar cannot receive touch events at the same time as the
738activity. This does <em>not</em> affect whether views inside the activity can split touch
739events&mdash;by default, the activity can still split touch events across views.</p>
740
741<p>For more information about creating a theme, read <a
742href="{@docRoot}guide/topics/ui/themes.html">Applying Styles and Themes</a>.</p>
743</li>
744</ul>
745
746
747
748<h3>WebKit</h3>
749
750<ul>
751  <li>New {@link android.webkit.WebViewFragment} class to create a fragment composed of a
752{@link android.webkit.WebView}.</li>
753  <li>New {@link android.webkit.WebSettings} methods:
754    <ul>
755      <li>{@link
756android.webkit.WebSettings#setDisplayZoomControls setDisplayZoomControls()} allows you to hide
757the on-screen zoom controls while still allowing the user to zoom with finger gestures ({@link
758android.webkit.WebSettings#setBuiltInZoomControls setBuiltInZoomControls()} must be set
759{@code true}).</li>
760      <li>New {@link android.webkit.WebSettings} method, {@link
761android.webkit.WebSettings#setEnableSmoothTransition setEnableSmoothTransition()}, allows you
762to enable smooth transitions when panning and zooming. When enabled, WebView will choose a solution
763to maximize the performance (for example, the WebView's content may not update during the
764transition).</li>
765    </ul>
766  <li>New {@link android.webkit.WebView} methods:
767    <ul>
768      <li>{@link android.webkit.WebView#onPause onPause()} callback, to pause any processing
769associated with the WebView when it becomes hidden. This is useful to reduce unnecessary CPU or
770network traffic when the WebView is not in the foreground.</li>
771      <li>{@link android.webkit.WebView#onResume onResume()} callback, to resume processing
772associated with the WebView, which was paused during {@link android.webkit.WebView#onPause
773onPause()}.</li>
774      <li>{@link android.webkit.WebView#saveWebArchive saveWebArchive()} allows you to save the
775current view as a web archive on the device.</li>
776      <li>{@link android.webkit.WebView#showFindDialog showFindDialog()} initiates a text search in
777the current view.</li>
778    </ul>
779  </li>
780</ul>
781
782
783
784<h3>Browser</h3>
785
786<p>The Browser application adds the following features to support web applications:</p>
787
788<ul>
789  <li><b>Media capture</b>
790    <p>As defined by the <a href="http://dev.w3.org/2009/dap/camera/">HTML Media Capture</a>
791specification, the Browser allows web applications to access audio, image and video capture
792capabilities of the device. For example, the following HTML provides an input for the user to
793capture a photo to upload:</p>
794<pre>
795&lt;input type="file" accept="image/*;capture=camera" />
796</pre>
797<p>Or by excluding the {@code capture=camera} parameter, the user can choose to either capture a
798new image with the camera or select one from the device (such as from the Gallery application).</p>
799  </li>
800
801  <li><b>Device Orientation</b>
802    <p>As defined by the <a
803href="http://dev.w3.org/geo/api/spec-source-orientation.html">Device Orientation Event</a>
804specification, the Browser allows web applications to listen to DOM events that provide information
805about the physical orientation and motion of the device.</p>
806    <p>The device orientation is expressed with the x, y, and z axes, in degrees and motion is
807expressed with acceleration and rotation rate data. A web page can register for orientation
808events by calling {@code window.addEventListener} with event type {@code "deviceorientation"}
809and register for motion events by registering the {@code "devicemotion"} event type.</p>
810  </li>
811
812  <li><b>CSS 3D Transforms</b>
813    <p>As defined by the <a href="http://www.w3.org/TR/css3-3d-transforms/">CSS 3D Transform
814Module</a> specification, the Browser allows elements rendered by CSS to be transformed in three
815dimensions.</p>
816  </li>
817</ul>
818
819
820
821<h3>JSON utilities</h3>
822
823<p>New classes, {@link android.util.JsonReader} and {@link android.util.JsonWriter}, help you
824read and write JSON streams. The new APIs complement the {@link org.json} classes, which manipulate
825a document in memory.</p>
826
827<p>You can create an instance of {@link android.util.JsonReader} by calling
828its constructor method and passing the {@link java.io.InputStreamReader} that feeds the JSON string.
829Then begin reading an object by calling {@link android.util.JsonReader#beginObject()}, read a
830key name with {@link android.util.JsonReader#nextName()}, read the value using methods
831respective to the type, such as {@link android.util.JsonReader#nextString()} and {@link
832android.util.JsonReader#nextInt()}, and continue doing so while {@link
833android.util.JsonReader#hasNext()} is true.</p>
834
835<p>You can create an instance of {@link android.util.JsonWriter} by calling its constructor and
836passing the appropriate {@link java.io.OutputStreamWriter}. Then write the JSON data in a manner
837similar to the reader, using {@link android.util.JsonWriter#name name()} to add a property name
838and an appropriate {@link android.util.JsonWriter#value value()} method to add the respective
839value.</p>
840
841<p>These classes are strict by default. The {@link android.util.JsonReader#setLenient setLenient()}
842method in each class configures them to be more liberal in what they accept. This lenient
843parse mode is also compatible with the {@link org.json}'s default parser.</p>
844
845
846
847
848<h3>New feature constants</h3>
849
850<p>The <a
851href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
852manfest element should be used to inform external entities (such as Google Play) of the set of
853hardware and software features on which your application depends. In this release, Android adds the
854following new constants that applications can declare with this element:</p>
855
856<ul>
857  <li>{@link android.content.pm.PackageManager#FEATURE_FAKETOUCH "android.hardware.faketouch"}
858    <p>When declared, this indicates that the application is compatible with a device that offers an
859emulated touchscreen (or better). A device that offers an emulated touchscreen provides a user input
860system that can emulate a subset of touchscreen
861capabilities. An example of such an input system is a mouse or remote control that drives an
862on-screen cursor. Such input systems support basic touch events like click down, click up, and drag.
863However, more complicated input types (such as gestures, flings, etc.) may be more difficult or
864impossible on faketouch devices (and multitouch gestures are definitely not possible).</p>
865    <p>If your application does <em>not</em> require complicated gestures and you do
866<em>not</em> want your application filtered from devices with an emulated touchscreen, you
867should declare {@link
868android.content.pm.PackageManager#FEATURE_FAKETOUCH "android.hardware.faketouch"} with a <a
869href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
870element. This way, your application will be available to the greatest number of device types,
871including those that provide only an emulated touchscreen input.</p>
872    <p>All devices that include a touchscreen also support {@link
873android.content.pm.PackageManager#FEATURE_FAKETOUCH "android.hardware.faketouch"}, because
874touchscreen capabilities are a superset of faketouch capabilities. Thus, unless you actually require
875a touchscreen, you should add a <a
876href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
877element for faketouch.</p>
878  </li>
879</ul>
880
881
882
883
884<h3>New permissions</h3>
885
886<ul>
887  <li>{@link android.Manifest.permission#BIND_REMOTEVIEWS
888"android.permission.BIND_REMOTEVIEWS"}
889  <p>This must be declared as a required permission in the <a
890href="{@docRoot}guide/topics/manifest/service-element.html">{@code &lt;service&gt;}</a> manifest
891element for an implementation of {@link android.widget.RemoteViewsService}. For example, when
892creating an App Widget that uses {@link android.widget.RemoteViewsService} to populate a
893collection view, the manifest entry may look like this:</p>
894<pre>
895&lt;service android:name=".widget.WidgetService"
896    android:exported="false"
897    android:permission="android.permission.BIND_REMOTEVIEWS" />
898</pre>
899</ul>
900
901
902
903<h3>New platform technologies</h3>
904
905<ul>
906<li><strong>Storage</strong>
907  <ul>
908  <li>ext4 file system support to enable onboard eMMC storage.</li>
909  <li>FUSE file system to support MTP devices.</li>
910  <li>USB host mode support to support keyboards and USB hubs.</li>
911  <li>Support for MTP/PTP </li>
912  </ul>
913</li>
914
915<li><strong>Linux Kernel</strong>
916  <ul>
917  <li>Upgraded to 2.6.36</li>
918  </ul>
919</li>
920
921<li><strong>Dalvik VM</strong>
922  <ul>
923  <li>New code to support and optimize for SMP</li>
924  <li>Various improvements to the JIT infrastructure</li>
925  <li>Garbage collector improvements:
926    <ul>
927    <li>Tuned for SMP</li>
928    <li>Support for larger heap sizes</li>
929    <li>Unified handling for bitmaps and byte buffers</li>
930    </ul>
931  </li>
932  </ul>
933</li>
934
935<li><strong>Dalvik Core Libraries</strong>
936  <ul>
937  <li>New, much faster implementation of NIO (modern I/O library)</li>
938  <li>Improved exception messages</li>
939  <li>Correctness and performance fixes throughout</li>
940  </ul>
941</li>
942</ul>
943
944
945
946<h3 id="api-diff">API differences report</h3>
947
948<p>For a detailed view of all API changes in Android {@sdkPlatformVersion} (API Level
949{@sdkPlatformApiLevel}), see the <a
950href="{@docRoot}sdk/api_diff/{@sdkPlatformApiLevel}/changes.html">API Differences Report</a>.</p>
951
952
953
954
955
956<h2 id="api-level">API Level</h2>
957
958<p>The Android {@sdkPlatformVersion} platform delivers an updated version of
959the framework API. The Android {@sdkPlatformVersion} API
960is assigned an integer identifier &mdash;
961<strong>{@sdkPlatformApiLevel}</strong> &mdash; that is
962stored in the system itself. This identifier, called the "API Level", allows the
963system to correctly determine whether an application is compatible with
964the system, prior to installing the application. </p>
965
966<p>To use APIs introduced in Android {@sdkPlatformVersion} in your application,
967you need compile the application against the Android library that is provided in
968the Android {@sdkPlatformVersion} SDK platform. Depending on your needs, you might
969also need to add an <code>android:minSdkVersion="{@sdkPlatformApiLevel}"</code>
970attribute to the <code>&lt;uses-sdk&gt;</code> element in the application's
971manifest. If your application is designed to run only on Android 2.3 and higher,
972declaring the attribute prevents the application from being installed on earlier
973versions of the platform.</p>
974
975<p>For more information, read <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">What is API
976Level?</a></p>
977