blob: 619c907bcc62cf39f1092d85d03635d4241f9d95 [file] [log] [blame]
Scott Main1d6f70c2011-10-06 22:57:25 -07001page.title=Android 4.0 Platform
2sdk.platform.version=4.0
3sdk.platform.apiLevel=14
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-diff">API Differences Report</a></li>
14 <li><a href="#api-level">API Level</a></li>
15 <li><a href="#apps">Built-in Applications</a></li>
16 <li><a href="#locs">Locales</a></li>
17 <li><a href="#skins">Emulator Skins</a></li>
18</ol>
19
20<h2>Reference</h2>
21<ol>
22<li><a
23href="{@docRoot}sdk/api_diff/14/changes.html">API
24Differences Report &raquo;</a> </li>
25</ol>
26
27</div>
28</div>
29
30
31<p><em>API Level:</em>&nbsp;<strong>{@sdkPlatformApiLevel}</strong></p>
32
33<p>Android 4.0 (Ice Cream Sandwich) is a major platform release that adds new
34capabilities for users and developers. The sections below provide an overview
35of the new features and developer APIs.</p>
36
37<p>For developers, the Android {@sdkPlatformVersion} platform is available as a
38downloadable component for the Android SDK. The downloadable platform includes
39an Android library and system image, as well as a set of emulator skins and
40more. The downloadable platform includes no external libraries.</p>
41
42<p>To start developing or testing against Android {@sdkPlatformVersion},
43use the Android SDK Manager to download the platform into your SDK. For more
44information, see <a href="{@docRoot}sdk/adding-components.html">Adding SDK
45Components</a>. If you are new to Android, <a
46href="{@docRoot}sdk/index.html">download the SDK Starter Package</a> first.</p>
47
48<p>For a high-level introduction to the new user and developer features in Android 4.0, see the
49<a href="http://developer.android.com/sdk/android-4.0-highlights.html">Platform Highlights</a>.</p>
50
51<p class="note"><strong>Reminder:</strong> If you've already published an
52Android application, please test your application on Android {@sdkPlatformVersion} as
53soon as possible to be sure your application provides the best
54experience possible on the latest Android-powered devices.</p>
55
56
57<h2 id="relnotes">Revisions</h2>
58
59<p>To determine what revision of the Android {@sdkPlatformVersion} platform you
60have installed, refer to the "Installed Packages" listing in the Android SDK Manager.</p>
61
62
63<div class="toggle-content opened" style="padding-left:1em;">
64
65 <p><a href="#" onclick="return toggleContent(this)">
66 <img src="{@docRoot}assets/images/triangle-opened.png"
67class="toggle-content-img" alt="" />
68 Android {@sdkPlatformVersion}, Revision 1</a> <em>(October 2011)</em>
69 </a></p>
70
71 <div class="toggle-content-toggleme" style="padding-left:2em;">
72
73<dl>
Robert Ly6cf7d9a2011-10-12 15:30:35 -070074<dt>Initial release. SDK Tools r14 or higher is required.
75<p class="note"><strong>Important:</strong> To download the new Android
764.0 system components from the Android SDK Manager, you must first update the
77SDK tools to revision 14 and restart the Android SDK Manager. If you do not,
78the Android 4.0 system components will not be available for download.</p>
79</dt>
Scott Main1d6f70c2011-10-06 22:57:25 -070080</dl>
81
82 </div>
83</div>
84
85
86<h2 id="api">API Overview</h2>
87
88<p>The sections below provide a technical overview of new APIs in Android 4.0.</p>
89
90<div class="toggle-content closed" style="padding-left:1em;">
91
92 <p><a href="#" onclick="return toggleContent(this)">
93 <img src="{@docRoot}assets/images/triangle-closed.png"
94class="toggle-content-img" alt="" />
95 <strong>Table of Contents</strong>
96 </a></p>
97
98 <div class="toggle-content-toggleme" style="padding-left:2em;">
99 <ol class="toc" style="margin-left:-1em">
100 <li><a href="#Contacts">Contacts</a></li>
101 <li><a href="#Calendar">Calendar</a></li>
102 <li><a href="#Camera">Camera</a></li>
103 <li><a href="#Multimedia">Multimedia</a></li>
104 <li><a href="#Bluetooth">Bluetooth</a></li>
105 <li><a href="#AndroidBeam">Android Beam (NDEF Push with NFC)</a></li>
106 <li><a href="#P2pWiFi">Peer-to-peer Wi-Fi</a></li>
107 <li><a href="#NetworkData">Network Data</a></li>
108 <li><a href="#Sensors">Device Sensors</a></li>
109 <li><a href="#Renderscript">Renderscript</a></li>
110 <li><a href="#A11y">Accessibility</a></li>
111 <li><a href="#Enterprise">Enterprise</a></li>
112 <li><a href="#Voicemail">Voicemail</a></li>
113 <li><a href="#SpellChecker">Spell Checker Services</a></li>
114 <li><a href="#TTS">Text-to-speech Engines</a></li>
115 <li><a href="#ActionBar">Action Bar</a></li>
116 <li><a href="#UI">User Interface and Views</a></li>
117 <li><a href="#Properties">Properties</a></li>
118 <li><a href="#HwAccel">Hardware Acceleration</a></li>
119 <li><a href="#Jni">JNI Changes</a></li>
120 <li><a href="#WebKit">WebKit</a></li>
121 <li><a href="#Permissions">Permissions</a></li>
122 <li><a href="#DeviceFeatures">Device Features</a></li>
123 </ol>
124 </div>
125</div>
126
127
128
129
130
131<h3 id="Contacts">Contacts</h3>
132
133<p>The Contact APIs that are defined by the {@link android.provider.ContactsContract} provider have
134been extended to support new features such as a personal profile for the device owner, large contact
135photos, and the ability for users to invite individual contacts to social networks that are
136installed on the device.</p>
137
138
139<h4>User Profile</h4>
140
141<p>Android now includes a personal profile that represents the device owner, as defined by the
142{@link
143android.provider.ContactsContract.Profile} table. Social apps that maintain a user identity can
144contribute to the user's profile data by creating a new {@link
145android.provider.ContactsContract.RawContacts} entry within the {@link
146android.provider.ContactsContract.Profile}. That is, raw contacts that represent the device user do
147not belong in the traditional raw contacts table defined by the {@link
148android.provider.ContactsContract.RawContacts} Uri; instead, you must add a profile raw contact in
149the table at {@link android.provider.ContactsContract.Profile#CONTENT_RAW_CONTACTS_URI}. Raw
150contacts in this table are then aggregated into the single user-visible profile information.</p>
151
152<p>Adding a new raw contact for the profile requires the {@link
153android.Manifest.permission#WRITE_PROFILE} permission. Likewise, in order to read from the profile
154table, you must request the {@link android.Manifest.permission#READ_PROFILE} permission. However,
155reading the user profile should not be required by most apps, even when contributing data to the
156profile. Reading the user profile is a sensitive permission and users will be very skeptical of apps
157that request reading their profile information.</p>
158
159<h4>Large photos</h4>
160
161<p>Android now supports high resolution photos for contacts. Now, when you push a photo into a
162contact
163record, the system processes it into both a 96x96 thumbnail (as it has previously) and a 256x256
164"display photo" stored in a new file-based photo store (the exact dimensions that the system chooses
165may vary in the future). You can add a large photo to a contact by putting a large photo in the
166usual {@link android.provider.ContactsContract.CommonDataKinds.Photo#PHOTO} column of a data row,
167which the system will then process into the appropriate thumbnail and display photo records.</p>
168
169<h4>Invite Intent</h4>
170
171<p>The {@link android.provider.ContactsContract.Intents#INVITE_CONTACT} intent action allows you to
172invoke an action that indicates the user wants to add a contact to a social network that understand
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700173this intent and use it to invite the contact specified in the contact to that social network.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700174
175<p>Apps that use a sync adapter to provide information about contacts can register with the system
176to
177receive the invite intent when there’s an opportunity for the user to “invite” a contact to the
178app’s social network (such as from a contact card in the People app). To receive the invite intent,
179you simply need to add the {@code inviteContactActivity} attribute to your app’s XML sync
180configuration file, providing a fully-qualified name of the activity that the system should start
181when the user wants to “invite” a contact in your social network. The activity that starts can then
182retrieve the URI for the contact in question from the intent’s data and perform the necessary work
183to
184invite that contact to the network or add the person to the user’s connections.</p>
185
186<h4>Contact Usage Feedback</h4>
187
188<p>The new {@link android.provider.ContactsContract.DataUsageFeedback} APIs allow you to help track
189how often the user uses particular methods of contacting people, such as how often the user uses
190each phone number or e-mail address. This information helps improve the ranking for each contact
191method associated with each person and provide such contact methods as suggestions.</p>
192
193
194
195
196
197<h3 id="Calendar">Calendar</h3>
198
199<p>The new calendar API allows you to access and modify the user’s calendars and events. The
200calendar
201APIs are provided with the {@link android.provider.CalendarContract} provider. Using the calendar
202provider, you can:</p>
203<ul>
204<li>Read, write, and modify calendars.</li>
205<li>Add and modify events, attendees, reminders, and alarms.</li>
206</ul>
207
208<p>{@link android.provider.CalendarContract} defines the data model of calendar and event-related
209information. All of the user’s calendar data is stored in a number of tables defined by subclasses
210of {@link android.provider.CalendarContract}:</p>
211
212<ul>
213<li>The {@link android.provider.CalendarContract.Calendars} table holds the calendar-specific
214information. Each row in this table contains the details for a single calendar, such as the name,
215color, sync information, and so on.</li>
216
217<li>The {@link android.provider.CalendarContract.Events} table holds event-specific information.
218Each
219row in this table has the information for a single event. It contains information such as event
220title, location, start time, end time, and so on. The event can occur one-time or can recur multiple
221times. Attendees, reminders, and extended properties are stored in separate tables and reference the
222event’s _ID to link them with the event.</li>
223
224<li>The {@link android.provider.CalendarContract.Instances} table holds the start and end time for
225occurrences of an event. Each row in this table represents a single occurrence. For one-time events
226there is a one-to-one mapping of instances to events. For recurring events, multiple rows are
227automatically generated to correspond to the multiple occurrences of that event.</li>
228
229<li>The {@link android.provider.CalendarContract.Attendees} table holds the event attendee or guest
230information. Each row represents a single guest of an event. It specifies the type of guest the
231person is and the person’s attendance response for the event.</li>
232
233<li>The {@link android.provider.CalendarContract.Reminders} table holds the alert/notification data.
234Each row represents a single alert for an event. An event can have multiple reminders. The number of
235reminders per event is specified in MAX_REMINDERS, which is set by the Sync Adapter that owns the
236given calendar. Reminders are specified in minutes before the event and have a type.</li>
237
238<li>The {@link android.provider.CalendarContract.ExtendedProperties} table hold opaque data fields
239used
240by the sync adapter. The provider takes no action with items in this table except to delete them
241when their related events are deleted.</li>
242</ul>
243
244<p>To access a user’s calendar data with the calendar provider, your application must request
245permission from the user by declaring <uses-permission
246android:name="android.permission.READ_CALENDAR" /> (for read access) and <uses-permission
247android:name="android.permission.WRITE_CALENDAR" /> (for write access) in their manifest files.</p>
248
249<p>However, if all you want to do is add an event to the user’s calendar, you can instead use an
250INSERT
251{@link android.content.Intent} to start an activity in the Calendar app that creates new events.
252Using the intent does not require the WRITE_CALENDAR permission and you can specify the {@link
253android.provider.CalendarContract#EXTRA_EVENT_BEGIN_TIME} and {@link
254android.provider.CalendarContract#EXTRA_EVENT_END_TIME} extra fields to pre-populate the form with
255the time of the event. The values for these times must be in milliseconds from the epoch. You must
256also specify {@code “vnd.android.cursor.item/event”} as the intent type.</p>
257
258
259
260
261
262<h3 id="Camera">Camera</h3>
263
264<p>The {@link android.hardware.Camera} APIs now support face detection and control for metering and
265focus areas.</p>
266
267<h4>Face Detection</h4>
268
269<p>Camera apps can now enhance their abilities with Android’s face detection software, which not
270only
271detects the face of a subject, but also specific facial features, such as the eyes and mouth. </p>
272
273<p>To detect faces in your camera application, you must register a {@link
274android.hardware.Camera.FaceDetectionListener} by calling {@link
275android.hardware.Camera#setFaceDetectionListener setFaceDetectionListener()}. You can then start
276your camera surface and start detecting faces by calling {@link
277android.hardware.Camera#startFaceDetection}.</p>
278
279<p>When the system detects a face, it calls the {@link
280android.hardware.Camera.FaceDetectionListener#onFaceDetection onFaceDetection()} callback in your
281implementation of {@link android.hardware.Camera.FaceDetectionListener}, including an array of
282{@link android.hardware.Camera.Face} objects.</p>
283
284<p>An instance of the {@link android.hardware.Camera.Face} class provides various information about
285the
286face detected by the camera, including:</p>
287<ul>
288<li>A {@link android.graphics.Rect} that specifies the bounds of the face, relative to the camera's
289current field of view</li>
290<li>An integer betwen 0 and 100 that indicates how confident the system is that the object is a
291human
292face</li>
293<li>A unique ID so you can track multiple faces</li>
294<li>Several {@link android.graphics.Point} objects that indicate where the eyes and mouth are
295located</li>
296</ul>
297
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700298
Scott Main1d6f70c2011-10-06 22:57:25 -0700299<h4>Focus and Metering Areas</h4>
300
301<p>Camera apps can now control the areas that the camera uses for focus and when metering white
302balance
303and auto-exposure (when supported by the hardware). Both features use the new {@link
304android.hardware.Camera.Area} class to specify the region of the camera’s current view that should
305be focused or metered. An instance of the {@link android.hardware.Camera.Area} class defines the
306bounds of the area with a {@link android.graphics.Rect} and the weight of the
307area&mdash;representing the level of importance of that area, relative to other areas in
308consideration&mdash;with an integer.</p>
309
310<p>Before setting either a focus area or metering area, you should first call {@link
311android.hardware.Camera.Parameters#getMaxNumFocusAreas} or {@link
312android.hardware.Camera.Parameters#getMaxNumMeteringAreas}, respectively. If these return zero, then
313the device does not support the respective feature. </p>
314
315<p>To specify the focus or metering areas to use, simply call {@link
316android.hardware.Camera.Parameters#setFocusAreas setFocusAreas()} or {@link
317android.hardware.Camera.Parameters#setFocusAreas setMeteringAreas()}. Each take a {@link
318java.util.List} of {@link android.hardware.Camera.Area} objects that indicate the areas to consider
319for focus or metering. For example, you might implement a feature that allows the user to set the
320focus area by touching an area of the preview, which you then translate to an {@link
321android.hardware.Camera.Area} object and set the focus to that spot. The focus or exposure in that
322area will continually update as the scene in the area changes.</p>
323
324
325<h4>Other Camera Features</h4>
326<ul>
327<li>Capture photos during video recording
328While recording video, you can now call {@link android.hardware.Camera#takePicture takePicture()} to
329save a photo without interrupting the video session. Before doing so, you should call {@link
330android.hardware.Camera.Parameters#isVideoSnapshotSupported} to be sure the hardware supports
331it.</li>
332
333<li>Lock auto exposure and white balance with {@link
334android.hardware.Camera.Parameters#setAutoExposureLock setAutoExposureLock()} and {@link
335android.hardware.Camera.Parameters#setAutoWhiteBalanceLock setAutoWhiteBalanceLock()}, to prevent
336these properties from changing.</li>
337</ul>
338
339<h4>Camera Broadcast Intents</h4>
340
341<ul>
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700342<li>{@link android.hardware.Camera#ACTION_NEW_PICTURE Camera.ACTION_NEW_PICTURE}
Scott Main1d6f70c2011-10-06 22:57:25 -0700343This indicates that the user has captured a new photo. The built-in camera app invokes this
344broadcast after a photo is captured and third-party camera apps should also broadcast this intent
345after capturing a photo.</li>
346<li>{@link android.hardware.Camera#ACTION_NEW_VIDEO Camera.ACTION_NEW_VIDEO}
347This indicates that the user has captured a new video. The built-in camera app invokes this
348broadcast after a video is recorded and third-party camera apps should also broadcast this intent
349after capturing a video.</li>
350</ul>
351
Scott Main1d6f70c2011-10-06 22:57:25 -0700352
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700353
354
355
Scott Main1d6f70c2011-10-06 22:57:25 -0700356<h3 id="Multimedia">Multimedia</h3>
357
358<p>Android 4.0 adds several new APIs for applications that interact with media such as photos,
359videos,
360and music.</p>
361
362
363<h4>Media Player</h4>
364
365<ul>
366<li>Streaming online media from {@link android.media.MediaPlayer} now requires {@link
367android.Manifest.permission#INTERNET} permission. If you use {@link android.media.MediaPlayer} to
368play content from the internet, be sure to add the {@link android.Manifest.permission#INTERNET}
369permission or else your media playback will not work beginning with Android 4.0.</li>
370<li>{@link android.media.MediaPlayer#setSurface(Surface) setSurface()} allows you define a {@link
371android.view.Surface} to behave as the video sink.</li>
372<li>{@link android.media.MediaPlayer#setDataSource(Context,Uri,Map) setDataSource()} allows you to
373send additional HTTP headers with your request, which can be useful for HTTP(S) live streaming</li>
374<li>HTTP(S) live streaming now respects HTTP cookies across requests</li>
375</ul>
376
377<h4>Media Type Support</h4>
378
379<p>Android 4.0 adds support for:</p>
380<ul>
381<li>HTTP/HTTPS live streaming protocol version 3 </li>
382<li>ADTS raw AAC audio encoding</li>
383<li>WEBP images</li>
384<li>Matroska video</li>
385</ul>
386<p>For more info, see <a href=”{@docRoot}guide/appendix/media-formats.html”>Supported Media
387Formats</a>.</p>
388
389
390<h4>Remote Control Client</h4>
391
392<p>The new {@link android.media.RemoteControlClient} allows media players to enable playback
393controls
394from remote control clients such as the device lock screen. Media players can also expose
395information about the media currently playing for display on the remote control, such as track
396information and album art.</p>
397
398<p>To enable remote control clients for your media player, instantiate a {@link
399android.media.RemoteControlClient} with a {@link android.app.PendingIntent} that broadcasts {@link
400android.content.Intent#ACTION_MEDIA_BUTTON}. The intent must also declare the explicit {@link
401android.content.BroadcastReceiver} component in your app that handles the {@link
402android.content.Intent#ACTION_MEDIA_BUTTON} event.</p>
403
404<p>To declare which media control inputs your player can handle, you must call {@link
405android.media.RemoteControlClient#setTransportControlFlags setTransportControlFlags()} on your
406{@link android.media.RemoteControlClient}, passing a set of {@code FLAG_KEY_MEDIA_*} flags, such as
407{@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PREVIOUS} and {@link
408android.media.RemoteControlClient#FLAG_KEY_MEDIA_NEXT}.</p>
409
410<p>You must then register your {@link android.media.RemoteControlClient} by passing it to {@link
411android.media.AudioManager#registerRemoteControlClient MediaManager.registerRemoteControlClient()}.
412Once registered, the broadcast receiver you declared when you instantiated the {@link
413android.media.RemoteControlClient} will receive {@link android.content.Intent#ACTION_MEDIA_BUTTON}
414events when a button is pressed from a remote control. The intent you receive includes the {@link
415android.view.KeyEvent} for the media key pressed, which you can retrieve from the intent with {@link
416android.content.Intent#getParcelableExtra getParcelableExtra(Intent.EXTRA_KEY_EVENT)}.</p>
417
418<p>To display information on the remote control about the media playing, call {@link
419android.media.RemoteControlClient#editMetadata editMetaData()} and add metadata to the returned
420{@link android.media.RemoteControlClient.MetadataEditor}. You can supply a bitmap for media artwork,
421numerical information such as elapsed time, and text information such as the track title. For
422information on available keys see the {@code METADATA_KEY_*} flags in {@link
423android.media.MediaMetadataRetriever}.</p>
424
425<p>For a sample implementation, see the <a
426href=”{@docRoot}resources/samples/RandomMusicPlayer/index.html”>Random Music Player</a>, which
427provides compatibility logic such that it enables the remote control client while continuing to
428support Android 2.1 devices.</p>
429
430
431<h4>Media Effects</h4>
432
433<p>A new media effects framework allows you to apply a variety of visual effects to images and
434videos.
435The system performs all effects processing on the GPU to obtain maximum performance. Applications in
436Android 4.0 such as Google Talk or the Gallery editor make use of the effects API to apply real-time
437effects to video and photos.</p>
438
439<p>For maximum performance, effects are applied directly to OpenGL textures, so your application
440must
441have a valid OpenGL context before it can use the effects APIs. The textures to which you apply
442effects may be from bitmaps, videos or even the camera. However, there are certain restrictions that
443textures must meet:</p>
444<ol>
445<li>They must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture image</li>
446<li>They must contain at least one mipmap level</li>
447</ol>
448
449<p>An {@link android.media.effect.Effect} object defines a single media effect that you can apply to
450an
451image frame. The basic workflow to create an {@link android.media.effect.Effect} is:</p>
452
453<ol>
454<li>Call {@link android.media.effect.EffectContext#createWithCurrentGlContext
455EffectContext.createWithCurrentGlContext()} from your OpenGL ES 2.0 context.</li>
456<li>Use the returned {@link android.media.effect.EffectContext} to call {@link
457android.media.effect.EffectContext#getFactory EffectContext.getFactory()}, which returns an instance
458of {@link android.media.effect.EffectFactory}.</li>
459<li>Call {@link android.media.effect.EffectFactory#createEffect createEffect()}, passing it an
460effect
461name from @link android.media.effect.EffectFactory}, such as {@link
462android.media.effect.EffectFactory#EFFECT_FISHEYE} or {@link
463android.media.effect.EffectFactory#EFFECT_VIGNETTE}.</li>
464</ol>
465
466<p>Not all devices support all effects, so you must first check if the desired effect is supported
467by
468calling {@link android.media.effect.EffectFactory#isEffectSupported isEffectSupported()}.</p>
469
470<p>You can adjust the effect’s parameters by calling {@link android.media.effect.Effect#setParameter
471setParameter()} and passing a parameter name and parameter value. Each type of effect accepts
472different parameters, which are documented with the effect name. For example, {@link
473android.media.effect.EffectFactory#EFFECT_FISHEYE} has one parameter for the {@code scale} of the
474distortion.</p>
475
476<p>To apply an effect on a texture, call {@link android.media.effect.Effect#apply apply()} on the
477{@link
478android.media.effect.Effect} and pass in the input texture, it’s width and height, and the output
479texture. The input texture must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture
480image (usually done by calling the {@link android.opengl.GLES20#glTexImage2D glTexImage2D()}
481function). You may provide multiple mipmap levels. If the output texture has not been bound to a
482texture image, it will be automatically bound by the effect as a {@link
483android.opengl.GLES20#GL_TEXTURE_2D}. It will contain one mipmap level (0), which will have the same
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700484size as the input.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700485
486
487
488
489
490
491
492<h3 id="Bluetooth">Bluetooth</h3>
493
494<p>Android now supports Bluetooth Health Profile devices, so you can create applications that use
495Bluetooth to communicate with health devices that support Bluetooth, such as heart-rate monitors,
496blood meters, thermometers, and scales.</p>
497
498<p>Similar to regular headset and A2DP profile devices, you must call {@link
499android.bluetooth.BluetoothAdapter#getProfileProxy getProfileProxy()} with a {@link
500android.bluetooth.BluetoothProfile.ServiceListener} and the {@link
501android.bluetooth.BluetoothProfile#HEALTH} profile type to establish a connection with the profile
502proxy object.</p>
503
504<p>Once you’ve acquired the Health profile proxy (the {@link android.bluetooth.BluetoothHealth}
505object), connecting to and communicating with paired health devices involves the following new
506Bluetooth classes:</p>
507<ul>
508<li>{@link android.bluetooth.BluetoothHealthCallback}: You must extend this class and implement the
509callback methods to receive updates about changes in the application’s registration state and
510Bluetooth channel state.</li>
511<li>{@link android.bluetooth.BluetoothHealthAppConfiguration}: During callbacks to your {@link
512android.bluetooth.BluetoothHealthCallback}, you’ll receive an instance of this object, which
513provides configuration information about the available Bluetooth health device, which you must use
514to perform various operations such as initiate and terminate connections with the {@link
515android.bluetooth.BluetoothHealth} APIs.</li>
516</ul>
517
518<p>For more information about using the Bluetooth Health profile, see the documentation for {@link
519android.bluetooth.BluetoothHealth}.</p>
520
521
522<h3 id="AndroidBeam">Android Beam (NDEF Push with NFC)</h3>
523
524<p>Android Beam allows you to send NDEF messages (an NFC standard for data stored on NFC tags) from
525one
526device to another (a process also known as “NDEF Push”). The data transfer is initiated when two
527Android-powered devices that support Android Beam are in close proximity (about 4 cm), usually with
528their backs touching. The data inside the NDEF message can contain any data that you wish to share
529between devices. For example, the People app shares contacts, YouTube shares videos, and Browser
530shares URLs using Android Beam.</p>
531
532<p>To transmit data between devices using Android Beam, you need to create an {@link
533android.nfc.NdefMessage} that contains the information you want to share while your activity is in
534the foreground. You must then pass the
535{@link android.nfc.NdefMessage} to the system in one of two ways:</p>
536
537<ul>
538<li>Define a single {@link android.nfc.NdefMessage} to use from the activity:
539<p>Call {@link android.nfc.NfcAdapter#setNdefPushMessage setNdefPushMessage()} at any time to set
540the
541message you want to send. For instance, you might call this method and pass it your {@link
542android.nfc.NdefMessage} during your activity’s {@link android.app.Activity#onCreate onCreate()}
543method. Then, whenever Android Beam is activated with another device while your activity is in the
544foreground, the system sends that {@link android.nfc.NdefMessage} to the other device.</p></li>
545
546<li>Define the {@link android.nfc.NdefMessage} depending on the current context:
547<p>Implement {@link android.nfc.NfcAdapter.CreateNdefMessageCallback}, in which the {@link
548android.nfc.NfcAdapter.CreateNdefMessageCallback#createNdefMessage createNdefMessage()} callback
549method returns the {@link android.nfc.NdefMessage} you want to send. Then pass the {@link
550android.nfc.NfcAdapter.CreateNdefMessageCallback} to {@link
551android.nfc.NfcAdapter#setNdefPushMessageCallback setNdefPushMessageCallback()}. In this case, when
552Android Beam is activated with another device while your activity is in the foreground, the system
553calls {@link android.nfc.NfcAdapter.CreateNdefMessageCallback#createNdefMessage createNdefMessage()}
554to retrieve the {@link android.nfc.NdefMessage} you want to send. This allows you to create a
555different {@link android.nfc.NdefMessage} for each occurrence, depending on the user context (such
556as which contact in the People app is currently visible).</p></li>
557</ul>
558
559<p>In case you want to run some specific code once the system has successfully delivered your NDEF
560message to the other device, you can implement {@link
561android.nfc.NfcAdapter.OnNdefPushCompleteCallback} and set it with {@link
562android.nfc.NfcAdapter#setOnNdefPushCompleteCallback setNdefPushCompleteCallback()}. The system will
563then call {@link android.nfc.NfcAdapter.OnNdefPushCompleteCallback#onNdefPushComplete
564onNdefPushComplete()} when the message is delivered.</p>
565
566<p>On the receiving device, the system dispatches NDEF Push messages in a similar way to regular NFC
567tags. The system invokes an intent with the {@link android.nfc.NfcAdapter#ACTION_NDEF_DISCOVERED}
568action to start an activity, with either a URL or a MIME type set according to the first {@link
569android.nfc.NdefRecord} in the {@link android.nfc.NdefMessage}. For the activity you want to
570respond, you can set intent filters for the URLs or MIME types your app cares about. For more
571information about Tag Dispatch see the <a
572href=”{@docRoot}guide/topics/nfc/index.html#dispatch”>NFC</a> developer guide.</p>
573
574<p>If you want your {@link android.nfc.NdefMessage} to carry a URI, you can now use the convenience
575method {@link android.nfc.NdefRecord#createUri createUri} to construct a new {@link
576android.nfc.NdefRecord} based on either a string or a {@link android.net.Uri} object. If the URI is
577a special format that you want your application to also receive during an Android Beam event, you
578should create an intent filter for your activity using the same URI scheme in order to receive the
579incoming NDEF message.</p>
580
581<p>You may also want to pass an “Android application record” with your {@link
582android.nfc.NdefMessage}
583in order to guarantee a specific application handles an NDEF message, regardless of whether other
584applications filter for the same intent. You can create an Android application record by calling
585{@link android.nfc.NdefRecord#createApplicationRecord createApplicationRecord()}, passing it the
586application’s package name. When the other device receives the NDEF message with this record, the
587system automatically starts the application matching the package name. If the target device does not
588currently have the application installed, the system uses the Android application record to launch
589Android Market and take the user to the application to install it.</p>
590
591<p>If your application doesn’t use NFC APIs to perform NDEF Push messaging, then Android provides a
592default behavior: When your application is in the foreground on one device and Android Beam is
593invoked with another Android-powered device, then the other device receives an NDEF message with an
594Android application record that identifies your application. If the receiving device has the
595application installed, the system launches it; if it’s not installed, Android Market opens and takes
596the user to your application so they can install it.</p>
597
598
599
600
601
602<h3 id="P2pWiFi">Peer-to-peer Wi-Fi</h3>
603
604<p>Android now supports Wi-Fi Direct&trade; for peer-to-peer (P2P) connections between
605Android-powered
606devices and other device types without a hotspot or Internet connection. The Android framework
607provides a set of Wi-Fi P2P APIs that allow you to discover and connect to other devices when each
608device supports Wi-Fi Direct&trade;, then communicate over a speedy connection across distances much
609longer than a Bluetooth connection.</p>
610
611<p>A new package, {@link android.net.wifi.p2p}, contains all the APIs for performing peer-to-peer
612connections with Wi-Fi. The primary class you need to work with is {@link
613android.net.wifi.p2p.WifiP2pManager}, for which you can get an instance by calling {@link
614android.app.Activity#getSystemService getSystemService(WIFI_P2P_SERVICE)}. The {@link
615android.net.wifi.p2p.WifiP2pManager} provides methods that allow you to:</p>
616<ul>
617<li>Initialize your application for P2P connections by calling {@link
618android.net.wifi.p2p.WifiP2pManager#initialize initialize()}</li>
619<li>Discover nearby devices by calling {@link android.net.wifi.p2p.WifiP2pManager#discoverPeers
620discoverPeers()}</li>
621<li>Start a P2P connection by calling {@link android.net.wifi.p2p.WifiP2pManager#connect
622connect()}</li>
623<li>And more</li>
624</ul>
625
626<p>Several other interfaces and classes are necessary as well, such as:</p>
627<ul>
628<li>The {@link android.net.wifi.p2p.WifiP2pManager.ActionListener} interface allows you to receive
629callbacks when an operation such as discovering peers or connecting to them succeeds or fails.</li>
630<li>{@link android.net.wifi.p2p.WifiP2pManager.PeerListListener} interface allows you to receive
631information about discovered peers. The callback provides a {@link
632android.net.wifi.p2p.WifiP2pDeviceList}, from which you can retrieve a {@link
633android.net.wifi.p2p.WifiP2pDevice} object for each device within range and get information such as
634the device name, address, device type, the WPS configurations the device supports, and more.</li>
635<li>The {@link android.net.wifi.p2p.WifiP2pManager.GroupInfoListener} interface allows you to
636receive
637information about a P2P group. The callback provides a {@link android.net.wifi.p2p.WifiP2pGroup}
638object, which provides group information such as the owner, the network name, and passphrase.</li>
639<li>{@link android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener} interface allows you to
640receive
641information about the current connection. The callback provides a {@link
642android.net.wifi.p2p.WifiP2pInfo} object, which has information such as whether a group has been
643formed and who is the group owner.</li>
644</ul>
645
646<p>In order to use the Wi-Fi P2P APIs, your app must request the following user permissions:</p>
647<ul>
648<li>{@link android.Manifest.permission#ACCESS_WIFI_STATE}</li>
649<li>{@link android.Manifest.permission#CHANGE_WIFI_STATE}</li>
650<li>{@link android.Manifest.permission#INTERNET} (even though your app doesn’t technically connect
651to
652the Internet, the WiFi Direct implementation uses traditional sockets that do require Internet
653permission to work).</li>
654</ul>
655
656<p>The Android system also broadcasts several different actions during certain Wi-Fi P2P events:</p>
657<ul>
658<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_CONNECTION_CHANGED_ACTION}: The P2P
659connection
660state has changed. This carries {@link android.net.wifi.p2p.WifiP2pManager#EXTRA_WIFI_P2P_INFO} with
661a {@link android.net.wifi.p2p.WifiP2pInfo} object and {@link
662android.net.wifi.p2p.WifiP2pManager#EXTRA_NETWORK_INFO} with a {@link android.net.NetworkInfo}
663object.</li>
664<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_CHANGED_ACTION}: The P2P state has
665changed
666between enabled and disabled. It carries {@link
667android.net.wifi.p2p.WifiP2pManager#EXTRA_WIFI_STATE} with either {@link
668android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_DISABLED} or {@link
669android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_ENABLED}</li>
670<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_PEERS_CHANGED_ACTION}: The list of peer
671devices
672has changed.</li>
673<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_THIS_DEVICE_CHANGED_ACTION}: The details for
674this device have changed.</li>
675</ul>
676
677<p>See the {@link android.net.wifi.p2p.WifiP2pManager} documentation for more information. Also
678look
679at the <a href=”{@docRoot}resources/samples/WiFiDirectDemo/index.html”>Wi-Fi Direct</a> sample
680application for example code.</p>
681
682
683
684
685
686<h3 id="NetworkData">Network Data</h3>
687
688<p>Android 4.0 gives users precise visibility of how much network data applications are using. The
689Settings app provides controls that allow users to manage set limits for network data usage and even
690disable the use of background data for individual apps. In order to avoid users disabling your app’s
691access to data from the background, you should develop strategies to use use the data connection
692efficiently and vary your usage depending on the type of connection available.</p>
693
694<p>If your application performs a lot of network transactions, you should provide user settings that
695allow users to control your app’s data habits, such as how often your app syncs data, whether to
696perform uploads/downloads only when on Wi-Fi, whether to use data while roaming, etc. With these
697controls available to them, users are much less likely to disable your app’s access to data when
698they approach their limits, because they can instead precisely control how much data your app uses.
699When you provide an activity with these settings, you should include in its manifest declaration an
700intent filter for the {@link android.content.Intent#ACTION_MANAGE_NETWORK_USAGE} action. For
701example:</p>
702
703<pre>
704&lt;activity android:name="DataPreferences" android:label="@string/title_preferences">
705 &lt;intent-filter>
706 &lt;action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
707 &lt;category android:name="android.intent.category.DEFAULT" />
708 &lt;/intent-filter>
709&lt;/activity>
710</pre>
711
712<p>This intent filter indicates to the system that this is the application that controls your
713application’s data usage. Thus, when the user inspects how much data your app is using from the
714Settings app, a “View application settings” button is available that launches your activity so the
715user can refine how much data your app uses.</p>
716
717<p>Also beware that {@link android.net.ConnectivityManager#getBackgroundDataSetting()} is now
718deprecated and always returns true&mdash;use {@link
719android.net.ConnectivityManager#getActiveNetworkInfo()} instead. Before you attempt any network
720transactions, you should always call {@link android.net.ConnectivityManager#getActiveNetworkInfo()}
721to get the {@link android.net.NetworkInfo} that represents the current network and query {@link
722android.net.NetworkInfo#isConnected()} to check whether the device has a
723connection. You can then check various other connection properties, such as whether the device is
724roaming or connected to Wi-Fi.</p>
725
726
727
728
729
730
731
732<h3 id="Sensors">Device Sensors</h3>
733
734<p>Two new sensor types have been added in Android 4.0: {@link
735android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE} and {@link
736android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY}. </p>
737
738<p>{@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE} is a temperature sensor that provides
739the ambient (room) temperature near a device. This sensor reports data in degrees Celsius. {@link
740android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY} is a humidity sensor that provides the relative
741ambient (room) humidity. The sensor reports data as a percentage. If a device has both {@link
742android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE} and {@link
743android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY} sensors, you can use them to calculate the dew point
744and the absolute humidity.</p>
745
746<p>The existing temperature sensor ({@link android.hardware.Sensor#TYPE_TEMPERATURE}) has been
747deprecated. You should use the {@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE} sensor
748instead.</p>
749
750<p>Additionally, Android’s three synthetic sensors have been improved so they now have lower latency
751and smoother output. These sensors include the gravity sensor ({@link
752android.hardware.Sensor#TYPE_GRAVITY}), rotation vector sensor ({@link
753android.hardware.Sensor#TYPE_ROTATION_VECTOR}), and linear acceleration sensor ({@link
754android.hardware.Sensor#TYPE_LINEAR_ACCELERATION}). The improved sensors rely on the gyroscope
755sensor to improve their output so the sensors appear only on devices that have a gyroscope. If a
756device already provides one of the sensors, then that sensor appears as a second sensor on the
757device. The three improved sensors have a version number of 2.</p>
758
759
760
761
762
763
764
765
766<h3 id="Renderscript">Renderscript</h3>
767
768<p>Three major features have been added to Renderscript:</p>
769
770<ul>
771 <li>Off-screen rendering to a framebuffer object</li>
772 <li>Rendering inside a view</li>
773 <li>RS for each from the framework APIs</li>
774</ul>
775
776<p>The {@link android.renderscript.Allocation} class now supports a {@link
777android.renderscript.Allocation#USAGE_GRAPHICS_RENDER_TARGET} memory space, which allows you to
778render things directly into the {@link android.renderscript.Allocation} and use it as a framebuffer
779object. </p>
780
781<p>{@link android.renderscript.RSTextureView} provides a means to display Renderscript graphics
782inside
783of a normal View, unlike {@link android.renderscript.RSSurfaceView}, which creates a separate
784window. This key difference allows you to do things such as move, transform, or animate an {@link
785android.renderscript.RSTextureView} as well as draw Renderscript graphics inside the View alongside
786other traditional View widgets.</p>
787
788<p>The {@link android.renderscript.Script#forEach forEach()} method allows you to call Renderscript
789compute scripts from the VM level and have them automatically delegated to available cores on the
790device. You do not use this method directly, but any compute Renderscript that you write will have a
791{@link android.renderscript.Script#forEach forEach()} method that you can call in the reflected
792Renderscript class. You can call the reflected {@link android.renderscript.Script#forEach forEach()}
793method by passing in an input {@link android.renderscript.Allocation} to process, an output {@link
794android.renderscript.Allocation} to write the result to, and a data structure if the Renderscript
795needs more information in addition to the {@link android.renderscript.Allocation}s to. Only one of
796the {@link android.renderscript.Allocation}s is necessary and the data structure is optional.</p>
797
798
799
800
801
802
803<h3 id="A11y">Accessibility</h3>
804
805<p>Android 4.0 improves accessibility for users with disabilities with the Touch Exploration service
806and provides extended APIs for developers of new accessibility services.</p>
807
808<h4>Touch Exploration</h4>
809
810<p>Users with vision loss can now explore applications by touching areas of the screen and hearing
811voice descriptions of the content. The “Explore by Touch” feature works like a virtual cursor as the
812user drags a finger across the screen.</p>
813
814<p>You don’t have to use any new APIs to enhance touch exploration in your application, because the
815existing {@link android.R.attr#contentDescription android:contentDescription}
816attribute and {@link android.view.View#setContentDescription setContentDescription()} method is all
817you need. Because touch exploration works like a virtual cursor, it allows screen readers to
818identify the descriptive the same way that screen readers can when navigating with a d-pad or
819trackball. So this is a reminder to provide descriptive text for the views in your application,
820especially for {@link android.widget.ImageButton}, {@link android.widget.EditText}, {@link
821android.widget.CheckBox} and other interactive widgets that might not contain text information by
822default.</p>
823
824<h4>Accessibility for Custom Views</h4>
825
826<p>Developers of custom Views, ViewGroups and widgets can make their components compatible with
827accessibility services like Touch Exploration. For custom views and widgets targeted for Android 4.0
828and later, developers should implement the following accessibility API methods in their classes:</p>
829<ul>
830<li>These two methods initiate the accessibility event generation process and must be implemented by
831your custom view class.
832 <ul>
833 <li>{@link android.view.View#sendAccessibilityEvent(int) sendAccessibilityEvent()} If
834accessibility
835 is
836 not enabled, this call has no effect.</li>
837 <li>{@link
838 android.view.View#sendAccessibilityEventUnchecked(android.view.accessibility.AccessibilityEvent)
839 sendAccessibilityEventUnchecked()} - This method executes regardless of whether accessibility is
840 enabled or not.</li>
841 </ul>
842</li>
843
844<li>These methods are called in order by the sendAccessibilityEvent methods listed above to collect
845accessibility information about the view, and its child views.
846 <ul>
847 <li>{@link
848 android.view.View#onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent)
849 onInitializeAccessibilityEvent()} - This method collects information about the view. If your
850 application has specific requirements for accessibility, you should extend this method to add that
851 information to the {@link android.view.accessibility.AccessibilityEvent}.</li>
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700852
Scott Main1d6f70c2011-10-06 22:57:25 -0700853 <li>{@link
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700854
Scott Main1d6f70c2011-10-06 22:57:25 -0700855android.view.View#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent)
856 dispatchPopulateAccessibilityEvent()} is called by the framework to request text information for
857 this view and its children. This method calls {@link
858 android.view.View#onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent)
859 onPopulateAccessibilityEvent()} first on the current view and then on its children.</li>
860 </ul>
861</li>
862
863<li>The {@link
864android.view.View#onInitializeAccessibilityNodeInfo onInitializeAccessibilityNodeInfo()} method
865provides additional context information for
866accessibility services. You should implement or override this method to provide improved information
867for accessibility services investigating your custom view.</li>
868
869<li>Custom {@link android.view.ViewGroup} classes should also implement {@link
870android.view.ViewGroup#onRequestSendAccessibilityEvent(android.view.View,
871android.view.accessibility.AccessibilityEvent) onRequestSendAccessibilityEvent()} </li>
872</ul>
873
874<p>Developers who want to maintain compatibility with Android versions prior to 4.0, while still
875providing support for new the accessibility APIs, can use the {@link
876android.view.View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)
877setAccessibilityDelegate()} method to provide an {@link android.view.View.AccessibilityDelegate}
878containing implementations of the new accessibility API methods while maintaining compatibility with
879prior releases.</p>
880
881
882
883<h4>Accessibility Service APIs</h4>
884
885<p>Accessibility events have been significantly improved to provide better information for
886accessibility services. In particular, events are generated based on view composition, providing
887better context information and allowing accessibility service developers to traverse view
888hierarchies to get additional view information and deal with special cases.</p>
889
890<p>To access additional content information and traverse view hierarchies, accessibility service
891application developers should use the following procedure.</p>
892<ol>
893<li>Upon receiving an {@link android.view.accessibility.AccessibilityEvent} from an application,
894call
895the {@link android.view.accessibility.AccessibilityEvent#getRecord(int)
896AccessibilityEvent.getRecord()} to retrieve new accessibility information about the state of the
897view.</li>
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700898<li>From the {@link android.view.accessibility.AccessibilityRecord}, call {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700899android.view.accessibility.AccessibilityRecord#getSource() getSource()} to retrieve a {@link
900android.view.accessibility.AccessibilityNodeInfo} object.</li>
901<li>With the {@link android.view.accessibility.AccessibilityNodeInfo}, call {@link
902android.view.accessibility.AccessibilityNodeInfo#getParent getParent()} or {@link
903android.view.accessibility.AccessibilityNodeInfo#getChild getChild()} to traverse the view
904hierarchy and get additional context information.</li>
905</ol>
906
907<p>In order to retrieve {@link android.view.accessibility.AccessibilityNodeInfo} information, your
908application must request permission to retrieve application window content through a manifest
909declaration that includes a new, separate xml configuration file, which supercedes {@link
910android.accessibilityservice.AccessibilityServiceInfo}. For more information, see {@link
911android.accessibilityservice.AccessibilityService} and {@link
912android.accessibilityservice.AccessibilityService#SERVICE_META_DATA
913AccessibilityService.SERVICE_META_DATA}.</p>
914
915
916
917
918
919
920<h3 id="Enterprise">Enterprise</h3>
921
922<p>Android 4.0 expands the capabilities for enterprise application with the following features.</p>
923
924<h4>VPN Services</h4>
925
926<p>The new {@link android.net.VpnService} allows applications to build their own VPN (Virtual
927Private
928Network), running as a {@link android.app.Service}. A VPN service creates an interface for a virtual
929network with its own address and routing rules and performs all reading and writing with a file
930descriptor.</p>
931
932<p>To create a VPN service, use {@link android.net.VpnService.Builder}, which allows you to specify
933the network address, DNS server, network route, and more. When complete, you can establish the
934interface by calling {@link android.net.VpnService.Builder#establish()}, which returns a {@link
935android.os.ParcelFileDescriptor}. </p>
936
937<p>Because a VPN service can intercept packets, there are security implications. As such, if you
938implement {@link android.net.VpnService}, then your service must require the {@link
939android.Manifest.permission#BIND_VPN_SERVICE} to ensure that only the system can bind to it (only
940the system is granted this permission&mdash;apps cannot request it). To then use your VPN service,
941users must manually enable it in the system settings.</p>
942
943
944<h4>Device Restrictions</h4>
945
946<p>Applications that manage the device restrictions can now disable the camera using {@link
947android.app.admin.DevicePolicyManager#setCameraDisabled setCameraDisabled()} and the {@link
948android.app.admin.DeviceAdminInfo#USES_POLICY_DISABLE_CAMERA} property (applied with a {@code
949&lt;disable-camera /&gt;} element in the policy configuration file).</p>
950
951
952<h4>Certificate Management</h4>
953
954<p>The new {@link android.security.KeyChain} class provides APIs that allow you to import and access
955certificates and key stores in credential storage. See the {@link android.security.KeyChain}
956documentation for more information.</p>
957
958
959
960
961<h3 id="Voicemail">Voicemail</h3>
962
963<p>A new voicemail APIs allows applications to add voicemails to the system. Because the APIs
964currently
965do not allow third party apps to read all the voicemails from the system, the only third-party apps
966that should use the voicemail APIs are those that have voicemail to deliver to the user. For
967instance, it’s possible that a users have multiple voicemail sources, such as one provided by their
968phone’s service provider and others from VoIP or other alternative services. These kinds of apps can
969use the APIs to add voicemail to the system. The built-in Phone application can then present all
970voicemails to the user with a single list. Although the system’s Phone application is the only
971application that can read all the voicemails, each application that provides voicemails can read
972those that it has added to the system.</p>
973
974<p>The {@link android.provider.VoicemailContract} class defines the content provider for the
975voicemail
976APIs. The subclasses {@link android.provider.VoicemailContract.Voicemails} and {@link
977android.provider.VoicemailContract.Status} provide tables in which the voicemail providers can
978insert voicemail data for storage on the device. For an example of a voicemail provider app, see the
979<a href=”{@docRoot}resources/samples/VoicemailProviderDemo/index.html”>Voicemail Provider
980Demo</a>.</p>
981
982
983
984
985<h3 id="SpellChecker">Spell Checker Services</h3>
986
987<p>The new spell checker framework allows apps to create spell checkers in a manner similar to the
988input method framework. To create a new spell checker, you must override the {@link
989android.service.textservice.SpellCheckerService.Session} class to provide spelling suggestions based
990on text provided by the interface callback methods, returning suggestions as a {@link
991android.view.textservice.SuggestionsInfo} object. </p>
992
993<p>Applications with a spell checker service must declare the {@link
994android.Manifest.permission#BIND_TEXT_SERVICE} permission as required by the service, such that
995other services must have this permission in order for them to bind with the spell checker service.
996The service must also declare an intent filter with <action
997android:name="android.service.textservice.SpellCheckerService" /> as the intent’s action and should
998include a {@code &lt;meta-data&gt;} element that declares configuration information for the spell
999checker. </p>
1000
1001
1002
1003
1004
1005<h3 id="TTS">Text-to-speech Engines</h3>
1006
1007<p>Android’s text-to-speech (TTS) APIs have been greatly extended to allow applications to more
1008easily
1009implement custom TTS engines, while applications that want to use a TTS engine have a couple new
1010APIs for selecting the engine.</p>
1011
1012
1013<h4>Using text-to-speech engines</h4>
1014
1015<p>In previous versions of Android, you could use the {@link android.speech.tts.TextToSpeech} class
1016to
1017perform text-to-speech (TTS) operations using the TTS engine provided by the system or set a custom
1018engine using {@link android.speech.tts.TextToSpeech#setEngineByPackageName
1019setEngineByPackageName()}.
1020In Android 4.0, the {@link android.speech.tts.TextToSpeech#setEngineByPackageName
1021setEngineByPackageName()} method has been deprecated and you can now specify the engine to use with
1022a new {@link android.speech.tts.TextToSpeech} that accepts the package name of a TTS engine.</p>
1023
1024<p>You can also query the available TTS engines with {@link
1025android.speech.tts.TextToSpeech#getEngines()}. This method returns a list of {@link
1026android.speech.tts.TextToSpeech.EngineInfo} objects, which include meta data such as the engine’s
1027icon, label, and package name.</p>
1028
1029
1030<h4>Building text-to-speech engines</h4>
1031
1032<p>Previously, custom engines required that the engine be built using native code, based on a TTS
1033engine header file. In Android 4.0, there is a framework API for building TTS engines. </p>
1034
1035<p>The basic setup requires an implementation of {@link android.speech.tts.TextToSpeechService} that
1036responds to the {@link android.speech.tts.TextToSpeech.Engine#INTENT_ACTION_TTS_SERVICE} intent. The
1037primary work for a TTS engine happens during the {@link
1038android.speech.tts.TextToSpeechService#onSynthesizeText onSynthesizeText()} callback in the {@link
1039android.speech.tts.TextToSpeechService}. The system delivers this method two objects:</p>
1040<ul>
1041<li>{@link android.speech.tts.SynthesisRequest}: This contains various data including the text to
1042synthesize, the locale, the speech rate, and voice pitch.</li>
1043<li>{@link android.speech.tts.SynthesisCallback}: This is the interface by which your TTS engine
1044delivers the resulting speech data as streaming audio, by calling {@link
1045android.speech.tts.SynthesisCallback#start start()} to indicate that the engine is ready to deliver
1046the
1047audio, then call {@link android.speech.tts.SynthesisCallback#audioAvailable audioAvailable()},
1048passing it the audio
1049data in a byte buffer. Once your engine has passed all audio through the buffer, call {@link
1050android.speech.tts.SynthesisCallback#done()}.</li>
1051</ul>
1052
1053<p>Now that the framework supports a true API for creating TTS engines, support for the previous
1054technique using native code has been removed. Watch for a blog post about the compatibility layer
1055that you can use to convert TTS engines built using the previous technique to the new framework.</p>
1056
1057<p>For an example TTS engine using the new APIs, see the <a
1058href=”{@docRoot}resources/samples/TtsEngine/index.html”>Text To Speech Engine</a> sample app.</p>
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070<h3 id="ActionBar">Action Bar</h3>
1071
1072<p>The {@link android.app.ActionBar} has been updated to support several new behaviors. Most
1073importantly, the system gracefully manages the action bar’s size and configuration when running on
1074smaller screens in order to provide an optimal user experience. For example, when the screen is
1075narrow (such as when a handset is in portrait orientation), the action bar’s navigation tabs appear
1076in a “stacked bar,” which appears directly below the main action bar. You can also opt-in to a
1077“split action bar,” which will place all action items in a separate bar at the bottom of the screen
1078when the screen is narrow.</p>
1079
1080
1081<h4>Split Action Bar</h4>
1082
1083<p>If your action bar includes several action items, not all of them will fit into the action bar
1084when on a narrow screen, so the system will place them into the overflow menu. However, Android 4.0
1085allows you to enable “split action bar” so that more action items can appear on the screen in a
1086separate bar at the bottom of the screen. To enable split action bar, add {@link
1087android.R.attr#uiOptions android:uiOptions} with {@code ”splitActionBarWhenNarrow”} to either your
1088{@code &lt;application&gt;} tag or individual {@code &lt;activity&gt;} tags in your manifest file.
1089When enabled, the system will enable the additional bar for action items when the screen is narrow
1090and add all action items to the new bar (no action items will appear in the primary action bar).</p>
1091
1092<p>If you want to use the navigation tabs provided by the {@link android.app.ActionBar.Tab} APIs,
1093but
1094don’t want the stacked bar&mdash;you want only the tabs to appear, then enable the split action bar
1095as described above and also call {@link android.app.ActionBar#setDisplayShowHomeEnabled
1096setDisplayShowHomeEnabled(false)} to disable the application icon in the action bar. With nothing
1097left in the main action bar, it disappears&mdash;all that’s left are the navigation tabs at the top
1098and the action items at the bottom of the screen.</p>
1099
1100
1101<h4>Action Bar Styles</h4>
1102
1103<p>If you want to apply custom styling to the action bar, you can use new style properties {@link
1104android.R.attr#backgroundStacked} and {@link android.R.attr#backgroundSplit} to apply a background
1105drawable or color to the stacked bar and split bar, respectively. You can also set these styles at
1106runtime with {@link android.app.ActionBar#setStackedBackgroundDrawable
1107setStackedBackgroundDrawable()} and {@link android.app.ActionBar#setSplitBackgroundDrawable
1108setSplitBackgroundDrawable()}.</p>
1109
1110
1111<h4>Action Provider</h4>
1112
1113<p>The new {@link android.view.ActionProvider} class facilitates user actions to which several
1114different applications may respond. For example, a “share” action in your application might invoke
1115several different apps that can handle the {@link android.content.Intent#ACTION_SEND} intent and the
1116associated data. In this case, you can use the {@link android.widget.ShareActionProvider} (an
1117extension of {@link android.view.ActionProvider}) in your action bar, instead of a traditional menu
1118item that invokes the intent. The {@link android.widget.ShareActionProvider} populates a drop-down
1119menu with all the available apps that can handle the intent.</p>
1120
1121<p>To declare an action provider for an action item, include the {@code android:actionProviderClass}
1122attribute in the {@code &lt;item&gt;} element for your activity’s options menu, with the class name
1123of the action provider as the attribute value. For example:</p>
1124
1125<pre>
1126&lt;item android:id="@+id/menu_share"
1127 android:title="Share"
1128 android:icon="@drawable/ic_share"
1129 android:showAsAction="ifRoom"
1130 android:actionProviderClass="android.widget.ShareActionProvider" /&gt;
1131</pre>
1132
1133<p>In your activity’s {@link android.app.Activity#onCreateOptionsMenu onCreateOptionsMenu()}
1134callback
1135method, retrieve an instance of the action provider from the menu item and set the intent:</p>
1136
1137<pre>
1138public boolean onCreateOptionsMenu(Menu menu) {
1139 getMenuInflater().inflate(R.menu.options, menu);
1140 ShareActionProvider shareActionProvider =
1141 (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider();
1142 // Set the share intent of the share action provider.
1143 shareActionProvider.setShareIntent(createShareIntent());
1144 ...
1145 return super.onCreateOptionsMenu(menu);
1146}
1147</pre>
1148
1149<p>For an example using the {@link android.widget.ShareActionProvider}, see the <a
1150href=”{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/ActionBarActionProviderActivity.html”>ActionBarActionProviderActivity</a>
1151class in ApiDemos.</p>
1152
1153
1154<h4>Collapsible Action Views</h4>
1155
1156<p>Menu items that appear as action items can now toggle between their action view state and
1157traditional action item state. Previously only the {@link android.widget.SearchView} supported
1158collapsing when used as an action view, but now you can add an action view for any action item and
1159switch between the expanded state (action view is visible) and collapsed state (action item is
1160visible).</p>
1161
1162<p>To declare that an action item that contains an action view be collapsible, include the {@code
1163“collapseActionView”} flag in the {@code android:showAsAction} attribute for the {@code
1164&lt;item&gt;} element in the menu’s XML file.</p>
1165
1166<p>To receive callbacks when an action view switches between expanded and collapsed, register an
1167instance of {@link android.view.MenuItem.OnActionExpandListener} with the respective {@link
1168android.view.MenuItem} by calling {@link android.view.MenuItem#setOnActionExpandListener
1169setOnActionExpandListener()}. Typically, you should do so during the {@link
1170android.app.Activity#onCreateOptionsMenu onCreateOptionsMenu()} callback.</p>
1171
1172<p>To control a collapsible action view, you can call {@link
1173android.view.MenuItem#collapseActionView()} and {@link android.view.MenuItem#expandActionView()} on
1174the respective {@link android.view.MenuItem}.</p>
1175
1176<p>When creating a custom action view, you can also implement the new {@link
1177android.view.CollapsibleActionView} interface to receive callbacks when the view is expanded and
1178collapsed.</p>
1179
1180
1181<h4>Other APIs for Action Bar</h4>
1182<ul>
1183<li>{@link android.app.ActionBar#setHomeButtonEnabled setHomeButtonEnabled()} allows you to disable
1184the
1185default behavior in which the application icon/logo behaves as a button (pass “false” to disable it
1186as a button).</li>
1187<li>{@link android.app.ActionBar#setIcon setIcon()} and {@link android.app.ActionBar#setLogo
1188setLogo()}
1189to define the action bar icon or logo at runtime.</li>
1190<li>{@link android.app.Fragment#setMenuVisibility Fragment.setMenuVisibility()} allows you to enable
1191or
1192disable the visibility of the options menu items declared by the fragment. This is useful if the
1193fragment has been added to the activity, but is not visible, so the menu items should be
1194hidden.</li>
1195<li>{@link android.app.FragmentManager#invalidateOptionsMenu
1196FragmentManager.invalidateOptionsMenu()}
1197allows you to invalidate the activity options menu during various states of the fragment lifecycle
1198in which using the equivalent method from {@link android.app.Activity} might not be available.</li>
1199</ul>
1200
1201
1202
1203
1204
1205
1206
1207
1208<h3 id="UI">User Interface and Views</h3>
1209
1210<p>Android 4.0 introduces a variety of new views and other UI components.</p>
1211
1212<h4>System UI</h4>
1213
1214<p>Since the early days of Android, the system has managed a UI component known as the <em>status
1215bar</em>, which resides at the top of handset devices to deliver information such as the carrier
1216signal, time, notifications, and so on. Android 3.0 added the <em>system bar</em> for tablet
1217devices, which resides at the bottom of the screen to provide system navigation controls (Home,
1218Back, and so forth) and also an interface for elements traditionally provided by the status bar. In
1219Android 4.0, the system provides a new type of system UI called the <em>navigation bar</em>. The
1220navigation bar shares some qualities with the system bar, because it provides navigation controls
1221for devices that don’t have hardware counterparts for navigating the system, but the navigation
1222controls is all that it provides (a device with the navigation bar, thus, also includes the status
1223bar at the top of the screen).</p>
1224
1225<p>To this day, you can hide the status bar on handsets using the {@link
1226android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN} flag. In Android 4.0, the APIs that control
1227the system bar’s visibility have been updated to better reflect the behavior of both the system bar
1228and navigation bar:</p>
1229<ul>
1230<li>The {@link android.view.View#SYSTEM_UI_FLAG_LOW_PROFILE} flag replaces View.STATUS_BAR_HIDDEN
1231flag
1232(now deprecated). When set, this flag enables “low profile” mode for the system bar or navigation
1233bar. Navigation buttons dim and other elements in the system bar also hide.</li>
1234<li>The {@link android.view.View#SYSTEM_UI_FLAG_VISIBLE} flag replaces the {@code
1235STATUS_BAR_VISIBLE}
1236flag to request the system bar or navigation bar be visible.</li>
1237<li>The {@link android.view.View#SYSTEM_UI_FLAG_HIDE_NAVIGATION} is a new flag that requests that
1238the
1239navigation bar hide completely. Take note that this works only for the <em>navigation bar</em> used
1240by some handsets (it does <strong>not</strong> hide the system bar on tablets). The navigation bar
1241returns as soon as the system receives user input. As such, this mode is generally used for video
1242playback or other cases in which user input is not required.</li>
1243</ul>
1244
1245<p>You can set each of these flags for the system bar by calling {@link
1246android.view.View#setSystemUiVisibility setSystemUiVisibility()} on any view in your activity
1247window. The window manager will combine (OR-together) all flags from all views in your window and
1248apply them to the system UI as long as your window has input focus. When your window loses input
1249focus (the user navigates away from your app, or a dialog appears), your flags cease to have effect.
1250Similarly, if you remove those views from the view hierarchy their flags no longer apply.</p>
1251
1252<p>To synchronize other events in your activity with visibility changes to the system UI (for
1253example,
1254hide the action bar or other UI controls when the system UI hides), you can register a {@link
1255android.view.View.OnSystemUiVisibilityChangeListener} to get a callback when the visibility
1256changes.</p>
1257
1258<p>See the <a
1259href=”{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/OverscanActivity.html”>
1260OverscanActivity</a> class for a demonstration of different system UI options.</p>
1261
1262
1263<h4>GridLayout</h4>
1264
1265<p>{@link android.widget.GridLayout} is a new view group that places child views in a rectangular
1266grid.
1267Unlike {@link android.widget.TableLayout}, {@link android.widget.GridLayout} relies on a flat
1268hierarchy and does not make use of intermediate views such as table rows for providing structure.
1269Instead, children specify which row(s) and column(s) they should occupy (cells can span multiple
1270rows and/or columns), and by default are laid out sequentially across the grid’s rows and columns.
1271The {@link android.widget.GridLayout} orientation determines whether sequential children are by
1272default laid out horizontally or vertically. Space between children may be specified either by using
1273instances of the new {@link android.widget.Space} view or by setting the relevant margin parameters
1274on children.</p>
1275
1276<p>See <a
1277href=”{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/index.html”>ApiDemos</a>
1278for samples using {@link android.widget.GridLayout}.</p>
1279
1280
1281
1282<h4>TextureView</h4>
1283
1284<p>{@link android.view.TextureView} is a new view that allows you to display a content stream, such
1285as
1286a video or an OpenGL scene. Although similar to {@link android.view.SurfaceView}, {@link
1287android.view.TextureView} is unique in that it behaves like a regular view, rather than creating a
1288separate window, so you can treat it like any other {@link android.view.View} object. For example,
1289you can apply transforms, animate it using {@link android.view.ViewPropertyAnimator}, or easily
1290adjust its opacity with {@link android.view.View#setAlpha setAlpha()}.</p>
1291
1292<p>Beware that {@link android.view.TextureView} works only within a hardware accelerated window.</p>
1293
1294<p>For more information, see the {@link android.view.TextureView} documentation.</p>
1295
1296
1297<h4>Switch Widget</h4>
1298
1299<p>The new {@link android.widget.Switch} widget is a two-state toggle that users can drag to one
1300side
1301or the other (or simply tap) to toggle an option between two states.</p>
1302
1303<p>You can declare a switch in your layout with the {@code &lt;Switch&gt;} element. You can use the
1304{@code android:textOn} and {@code android:textOff} attributes to specify the text to appear on the
1305switch when in the on and off setting. The {@code android:text} attribute also allows you to place a
1306label alongside the switch.</p>
1307
1308<p>For a sample using switches, see the <a
1309href=”{@docRoot}resources/samples/ApiDemos/res/layout/switches.html”>switches.xml</a> layout file
1310and respective <a
1311href=”{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/Switches.html”>Switches
1312</a> activity.</p>
1313
1314
1315<h4>Popup Menus</h4>
1316
1317<p>Android 3.0 introduced {@link android.widget.PopupMenu} to create short contextual menus that pop
1318up
1319at an anchor point you specify (usually at the point of the item selected). Android 4.0 extends the
1320{@link android.widget.PopupMenu} with a couple useful features:</p>
1321<ul>
1322<li>You can now easily inflate the contents of a popup menu from an XML <a
1323href=”{@docRoot}guide/topics/resources/menu-resource.html”>menu resource</a> with {@link
1324android.widget.PopupMenu#inflate inflate()}, passing it the menu resource ID.</li>
1325<li>You can also now create a {@link android.widget.PopupMenu.OnDismissListener} that receives a
1326callback when the menu is dismissed.</li>
1327</ul>
1328
1329<h4>Preferences</h4>
1330
1331<p>A new {@link android.preference.TwoStatePreference} abstract class serves as the basis for
1332preferences that provide a two-state selection option. The new {@link
1333android.preference.SwitchPreference} is an extension of {@link
1334android.preference.TwoStatePreference} that provides a {@link android.widget.Switch} widget in the
1335preference view to allow users to toggle a setting on or off without the need to open an additional
1336preference screen or dialog. For example, the Settings application uses a {@link
1337android.preference.SwitchPreference} for the Wi-Fi and Bluetooth settings.</p>
1338
1339
1340<h4>Hover Events</h4>
1341
1342<p>The {@link android.view.View} class now supports “hover” events to enable richer interactions
1343through the use of pointer devices (such as a mouse or other device that drives an on-screen
1344cursor).</p>
1345
1346<p>To receive hover events on a view, implement the {@link android.view.View.OnHoverListener} and
1347register it with {@link android.view.View#setOnHoverListener setOnHoverListener()}. When a hover
1348event occurs on the view, your listener receives a call to {@link
1349android.view.View.OnHoverListener#onHover onHover()}, providing the {@link android.view.View} that
1350received the event and a {@link android.view.MotionEvent} that describes the type of hover event
1351that occurred. The hover event can be one of the following:</p>
1352<ul>
1353<li>{@link android.view.MotionEvent#ACTION_HOVER_ENTER}</li>
1354<li>{@link android.view.MotionEvent#ACTION_HOVER_EXIT}</li>
1355<li>{@link android.view.MotionEvent#ACTION_HOVER_MOVE}</li>
1356</ul>
1357
1358<p>Your {@link android.view.View.OnHoverListener} should return true from {@link
1359android.view.View.OnHoverListener#onHover onHover()} if it handles the hover event. If your
1360listener returns false, then the hover event will be dispatched to the parent view as usual.</p>
1361
1362<p>If your application uses buttons or other widgets that change their appearance based on the
1363current
1364state, you can now use the {@code android:state_hovered} attribute in a <a
1365href=”{@docRoot}guide/topics/resources/drawable-resource.html#StateList”>state list drawable</a> to
1366provide a different background drawable when a cursor hovers over the view.</p>
1367
1368<p>For a demonstration of the new hover events, see the <a
1369href=”{@docRoot}samples/ApiDemos/src/com/example/android/apis/view/Hover.html”>Hover</a> class in
1370ApiDemos.</p>
1371
1372
1373<h4>Stylus and Mouse Button Input Events</h4>
1374
1375<p>Android now provides APIs for receiving input from a stylus input device such as a digitizer
1376tablet
1377peripheral or a stylus-enabled touch screen.</p>
1378
1379<p>Stylus input operates in a similar manner to touch or mouse input. When the stylus is in contact
1380with the digitizer, applications receive touch events just like they would when a finger is used to
1381touch the display. When the stylus is hovering above the digitizer, applications receive hover
1382events just like they would when a mouse pointer was being moved across the display when no buttons
1383are pressed.</p>
1384
1385<p>Your application can distinguish between finger, mouse, stylus and eraser input by querying the
1386“tool type” associated with each pointer in a {@link android.view.MotionEvent} using {@link
1387android.view.MotionEvent#getToolType getToolType()}. The currently defined tool types are: {@link
1388android.view.MotionEvent#TOOL_TYPE_UNKNOWN}, {@link android.view.MotionEvent#TOOL_TYPE_FINGER},
1389{@link android.view.MotionEvent#TOOL_TYPE_MOUSE}, {@link android.view.MotionEvent#TOOL_TYPE_STYLUS},
1390and {@link android.view.MotionEvent#TOOL_TYPE_ERASER}. By querying the tool type, your application
1391can choose to handle stylus input in different ways from finger or mouse input.</p>
1392
1393<p>Your application can also query which mouse or stylus buttons are pressed by querying the “button
1394state” of a {@link android.view.MotionEvent} using {@link android.view.MotionEvent#getButtonState
1395getButtonState()}. The currently defined button states are: {@link
1396android.view.MotionEvent#BUTTON_PRIMARY}, {@link
1397android.view.MotionEvent#BUTTON_SECONDARY}, {@link
1398android.view.MotionEvent#BUTTON_TERTIARY}, {@link android.view.MotionEvent#BUTTON_BACK},
1399and {@link android.view.MotionEvent#BUTTON_FORWARD}.
1400For convenience, the back and forward mouse buttons are automatically mapped to the {@link
1401android.view.KeyEvent#KEYCODE_BACK} and {@link android.view.KeyEvent#KEYCODE_FORWARD} keys. Your
1402application can handle these keys to support mouse button based back and forward navigation.</p>
1403
1404<p>In addition to precisely measuring the position and pressure of a contact, some stylus input
1405devices
1406also report the distance between the stylus tip and the digitizer, the stylus tilt angle, and the
1407stylus orientation angle. Your application can query this information using {@link
1408android.view.MotionEvent#getAxisValue getAxisValue()} with the axis codes {@link
1409android.view.MotionEvent#AXIS_DISTANCE}, {@link android.view.MotionEvent#AXIS_TILT}, and {@link
1410android.view.MotionEvent#AXIS_ORIENTATION}.</p>
1411
1412<p>For a demonstration of tool types, button states and the new axis codes, see the <a
1413href=”{@docRoot}samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html”>TouchPaint
1414</a> class in ApiDemos.</p>
1415
1416
1417
1418
1419
1420
1421<h3 id="Properties">Properties</h3>
1422
1423<p>The new {@link android.util.Property} class provides a fast, efficient, and easy way to specify a
1424property on any object that allows callers to generically set/get values on target objects. It also
1425allows the functionality of passing around field/method references and allows code to set/get values
1426of the property without knowing the details of what the fields/methods are.</p>
1427
1428<p>For example, if you want to set the value of field {@code bar} on object {@code foo}, you would
1429previously do this:</p>
1430<pre>
1431foo.bar = value;
1432</pre>
1433
1434<p>If you want to call the setter for an underlying private field {@code bar}, you would previously
1435do this:</p>
1436<pre>
1437foo.setBar(value);
1438</pre>
1439
1440<p>However, if you want to pass around the {@code foo} instance and have some other code set the
1441{@code bar} value, there is really no way to do it prior to Android 4.0.</p>
1442
1443<p>Using the {@link android.util.Property} class, you can declare a {@link android.util.Property}
1444object {@code BAR} on class {@code Foo} so that you can set the field on instance {@code foo} of
1445class {@code Foo} like this:</p>
1446<pre>
1447BAR.set(foo, value);
1448</pre>
1449
1450<p>The {@link android.view.View} class now leverages the {@link android.util.Property} class to
1451allow you to set various fields, such as transform properties that were added in Android 3.0 ({@link
1452android.view.View#ROTATION}, {@link android.view.View#ROTATION_X}, {@link
1453android.view.View#TRANSLATION_X}, etc.).</p>
1454
1455<p>The {@link android.animation.ObjectAnimator} class also uses the {@link android.util.Property}
1456class, so you can create an {@link android.animation.ObjectAnimator} with a {@link
1457android.util.Property}, which is faster, more efficient, and more type-safe than the string-based
1458approach.</p>
1459
1460
1461
1462
1463
1464
1465<h3 id="HwAccel">Hardware Acceleration</h3>
1466
1467<p>Beginning with Android 4.0, hardware acceleration for all windows is enabled by default if your
1468application has set either <a
1469href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> or
1470<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> to
1471{@code “14”} or higher. Hardware acceleration generally results in smoother animations, smoother
1472scrolling, and overall better performance and response to user interaction.</p>
1473
1474<p>If necessary, you can manually disable hardware acceleration with the <a
1475href=”{@docRoot}guide/topics/manifest/activity-element.html#hwaccel”>{@code hardwareAccelerated}</a>
1476attribute for individual <a href="{@docRoot}guide/topics/manifest/activity-element.html">{@code
1477&lt;activity&gt;}</a> elements or the <a
1478href="{@docRoot}guide/topics/manifest/application-element.html">{@code &lt;application&gt;}</a>
1479element. You can alternatively disable hardware acceleration for individual views by calling {@link
1480android.view.View#setLayerType setLayerType(LAYER_TYPE_SOFTWARE)}.</p>
1481
1482
1483<h3 id="Jni">JNI Changes</h3>
1484
1485<p>In previous versions of Android, JNI local references weren’t indirect handles; we used direct
1486pointers. This didn’t seem like a problem as long as we didn’t have a garbage collector that moves
1487objects, but it was because it meant that it was possible to write buggy code that still seemed to
1488work. In Android 4.0, we’ve moved to using indirect references so we can detect these bugs before we
1489need third-party native code to be correct.</p>
1490
1491<p>The ins and outs of JNI local references are described in “Local and Global References” in
1492<a href="{@docRoot}guide/practices/design/jni.html">JNI Tips</a>. In Android 4.0, <a
1493href="http://android-developers.blogspot.com/2011/07/debugging-android-jni-with-checkjni.html">CheckJNI</a>
1494has been
1495enhanced to detect these errors. Watch the <a href=”http://android-developers.blogspot.com/”>Android
1496Developers Blog</a> for an upcoming post about common errors with JNI references and how you can fix
1497them.</p>
1498
1499<p>This change in the JNI implementation only affects apps that target Android 4.0 by setting either
1500the <a
1501href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> or
1502<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> to
1503{@code “14”} or higher. If you’ve set these attributes to any lower
1504value, then JNI local references will behave the same as in previous versions.</p>
1505
1506
1507
1508
1509
1510<h3 id="WebKit">WebKit</h3>
1511<ul>
1512<li>WebKit updated to version 534.30</li>
1513<li>Support for Indic fonts (Devanagari, Bengali, and Tamil, including the complex character support
1514needed for combining glyphs) in {@link android.webkit.WebView} and the built-in Browser</li>
1515<li>Support for Ethiopic, Georgian, and Armenian fonts in {@link android.webkit.WebView} and the
1516built-in Browser</li>
1517<li>Support for <a
1518href="http://google-opensource.blogspot.com/2009/05/introducing-webdriver.html">WebDriver</a> makes
1519it easier for you to test apps that use {@link android.webkit.WebView}</li>
1520</ul>
1521
1522
1523<h4>Android Browser</h4>
1524
1525<p>The Browser application adds the following features to support web applications:</p>
1526<ul>
1527<li>Updated V8 JavaScript compiler for faster performance</li>
1528<li>Plus other notable enhancements carried over from <a
1529href=”{@docRoot}sdk/android-3.0.html”>Android
15303.0</a> are now available for handsets:
1531<ul>
1532<li>Support for fixed position elements on all pages</li>
1533<li><a href="http://dev.w3.org/2009/dap/camera/">HTML media capture</a></li>
1534<li><a href="http://dev.w3.org/geo/api/spec-source-orientation.html">Device orientation
1535events</a></li>
1536<li><a href="http://www.w3.org/TR/css3-3d-transforms/">CSS 3D transformations</a></li>
1537</ul>
1538</li>
1539</ul>
1540
1541
1542
1543<h3 id="Permissions">Permissions</h3>
1544
1545<p>The following are new permissions:</p>
1546<ul>
1547<li>{@link android.Manifest.permission#ADD_VOICEMAIL}: Allows a voicemail service to add voicemail
1548messages to the device.</li>
1549<li>{@link android.Manifest.permission#BIND_TEXT_SERVICE}: A service that implements {@link
1550android.service.textservice.SpellCheckerService} must require this permission for itself.</li>
1551<li>{@link android.Manifest.permission#BIND_VPN_SERVICE}: A service that implements {@link
1552android.net.VpnService} must require this permission for itself.</li>
1553<li>{@link android.Manifest.permission#READ_PROFILE}: Provides read access to the {@link
1554android.provider.ContactsContract.Profile} provider.</li>
1555<li>{@link android.Manifest.permission#WRITE_PROFILE}: Provides write access to the {@link
1556android.provider.ContactsContract.Profile} provider.</li>
1557</ul>
1558
1559
1560
1561<h3 id="DeviceFeatures">Device Features</h3>
1562
1563<p>The following are new device features:</p>
1564<ul>
1565<li>{@link android.content.pm.PackageManager#FEATURE_WIFI_DIRECT}: Declares that the application
1566uses
1567Wi-Fi for peer-to-peer communications.</li>
1568</ul>
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580<h2 id="api-diff">API Differences Report</h2>
1581
1582<p>For a detailed view of all API changes in Android {@sdkPlatformVersion} (API
1583Level
1584{@sdkPlatformApiLevel}), see the <a
1585href="{@docRoot}sdk/api_diff/{@sdkPlatformApiLevel}/changes.html">API
1586Differences Report</a>.</p>
1587
1588
1589
1590
1591
1592<h2 id="api-level">API Level</h2>
1593
1594<p>The Android {@sdkPlatformVersion} platform delivers an updated version of the framework API. The
1595Android {@sdkPlatformVersion} API is assigned an integer identifier &mdash;
1596<strong>{@sdkPlatformApiLevel}</strong> &mdash; that is stored in the system itself. This
1597identifier, called the "API Level", allows the system to correctly determine whether an application
1598is compatible with the system, prior to installing the application. </p>
1599
1600<p>To use APIs introduced in Android {@sdkPlatformVersion} in your application, you need compile the
1601application against the Android library that is provided in the Android {@sdkPlatformVersion} SDK
1602platform. Depending on your needs, you might also need to add an
1603<code>android:minSdkVersion="{@sdkPlatformApiLevel}"</code> attribute to the
1604<code>&lt;uses-sdk&gt;</code> element in the application's manifest.</p>
1605
1606<p>For more information about how to use API Level, see the <a
1607href="{@docRoot}guide/appendix/api-levels.html">API Levels</a> document. </p>
1608
1609
1610<h2 id="apps">Built-in Applications</h2>
1611
1612<p>The system image included in the downloadable platform provides these
1613built-in applications:</p>
1614
1615<table style="border:0;padding-bottom:0;margin-bottom:0;">
1616<tr>
1617<td style="border:0;padding-bottom:0;margin-bottom:0;">
1618<ul>
1619<li>API Demos</li>
1620<li>Browser</li>
1621<li>Calculator</li>
1622<li>Camera</li>
1623<li>Clock</li>
1624<li>Custom Locale</li>
1625<li>Dev Tools</li>
1626<li>Downloads</li>
1627<li>Email</li>
1628<li>Gallery</li>
1629</ul>
1630</td>
1631<td style="border:0;padding-bottom:0;margin-bottom:0;padding-left:5em;">
1632<ul>
1633<li>Gestures Builder</li>
1634<li>Messaging</li>
1635<li>Music</li>
1636<li>People</li>
1637<li>Phone</li>
1638<li>Search</li>
1639<li>Settings</li>
1640<li>Spare Parts</li>
1641<li>Speech Recorder</li>
1642<li>Widget Preview</li>
1643</ul>
1644</td>
1645</tr>
1646</table>
1647
1648
1649<h2 id="locs" style="margin-top:.75em;">Locales</h2>
1650
1651<p>The system image included in the downloadable SDK platform provides a variety
1652of
1653built-in locales. In some cases, region-specific strings are available for the
1654locales. In other cases, a default version of the language is used. The
1655languages that are available in the Android 3.0 system
1656image are listed below (with <em>language</em>_<em>country/region</em> locale
1657descriptor).</p>
1658
1659<table style="border:0;padding-bottom:0;margin-bottom:0;">
1660<tr>
1661<td style="border:0;padding-bottom:0;margin-bottom:0;">
1662<ul>
1663<li>Arabic, Egypt (ar_EG)</li>
1664<li>Arabic, Israel (ar_IL)</li>
1665<li>Bulgarian, Bulgaria (bg_BG)</li>
1666<li>Catalan, Spain (ca_ES)</li>
1667<li>Czech, Czech Republic (cs_CZ)</li>
1668<li>Danish, Denmark(da_DK)</li>
1669<li>German, Austria (de_AT)</li>
1670<li>German, Switzerland (de_CH)</li>
1671<li>German, Germany (de_DE)</li>
1672<li>German, Liechtenstein (de_LI)</li>
1673<li>Greek, Greece (el_GR)</li>
1674<li>English, Australia (en_AU)</li>
1675<li>English, Canada (en_CA)</li>
1676<li>English, Britain (en_GB)</li>
1677<li>English, Ireland (en_IE)</li>
1678<li>English, India (en_IN)</li>
1679<li>English, New Zealand (en_NZ)</li>
1680<li>English, Singapore(en_SG)</li>
1681<li>English, US (en_US)</li>
1682<li>English, Zimbabwe (en_ZA)</li>
1683<li>Spanish (es_ES)</li>
1684<li>Spanish, US (es_US)</li>
1685<li>Finnish, Finland (fi_FI)</li>
1686<li>French, Belgium (fr_BE)</li>
1687<li>French, Canada (fr_CA)</li>
1688<li>French, Switzerland (fr_CH)</li>
1689<li>French, France (fr_FR)</li>
1690<li>Hebrew, Israel (he_IL)</li>
1691<li>Hindi, India (hi_IN)</li>
1692</ul>
1693</td>
1694<td style="border:0;padding-bottom:0;margin-bottom:0;padding-left:5em;">
1695<li>Croatian, Croatia (hr_HR)</li>
1696<li>Hungarian, Hungary (hu_HU)</li>
1697<li>Indonesian, Indonesia (id_ID)</li>
1698<li>Italian, Switzerland (it_CH)</li>
1699<li>Italian, Italy (it_IT)</li>
1700<li>Japanese (ja_JP)</li>
1701<li>Korean (ko_KR)</li>
1702<li>Lithuanian, Lithuania (lt_LT)</li>
1703<li>Latvian, Latvia (lv_LV)</li>
1704<li>Norwegian bokmål, Norway (nb_NO)</li>
1705<li>Dutch, Belgium (nl_BE)</li>
1706<li>Dutch, Netherlands (nl_NL)</li>
1707<li>Polish (pl_PL)</li>
1708<li>Portuguese, Brazil (pt_BR)</li>
1709<li>Portuguese, Portugal (pt_PT)</li>
1710<li>Romanian, Romania (ro_RO)</li>
1711<li>Russian (ru_RU)</li></li>
1712<li>Slovak, Slovakia (sk_SK)</li>
1713<li>Slovenian, Slovenia (sl_SI)</li>
1714<li>Serbian (sr_RS)</li>
1715<li>Swedish, Sweden (sv_SE)</li>
1716<li>Thai, Thailand (th_TH)</li>
1717<li>Tagalog, Philippines (tl_PH)</li>
1718<li>Turkish, Turkey (tr_TR)</li>
1719<li>Ukrainian, Ukraine (uk_UA)</li>
1720<li>Vietnamese, Vietnam (vi_VN)</li>
1721<li>Chinese, PRC (zh_CN)</li>
1722<li>Chinese, Taiwan (zh_TW)</li>
1723</td>
1724</tr>
1725</table>
1726
1727<p class="note"><strong>Note:</strong> The Android platform may support more
1728locales than are included in the SDK system image. All of the supported locales
1729are available in the <a href="http://source.android.com/">Android Open Source
1730Project</a>.</p>
1731
1732<h2 id="skins">Emulator Skins</h2>
1733
1734<p>The downloadable platform includes the following emulator skin:</p>
1735
1736<ul>
1737 <li>
1738 WVGA800 (1280x800, extra high density, normal screen)
1739 </li>
1740</ul>
1741
1742<p>For more information about how to develop an application that displays
1743and functions properly on all Android-powered devices, see <a
1744href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
1745Screens</a>.</p>