blob: b4fbe724979bbd39d0f24a78d99bb4a3aa3cd5c6 [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>
Scott Maine1e9e932011-10-13 23:36:19 -070013 <li><a href="#Honeycomb">Previous APIs</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -070014 <li><a href="#api-diff">API Differences Report</a></li>
15 <li><a href="#api-level">API Level</a></li>
16 <li><a href="#apps">Built-in Applications</a></li>
17 <li><a href="#locs">Locales</a></li>
18 <li><a href="#skins">Emulator Skins</a></li>
19</ol>
20
21<h2>Reference</h2>
22<ol>
23<li><a
24href="{@docRoot}sdk/api_diff/14/changes.html">API
25Differences Report &raquo;</a> </li>
26</ol>
27
28</div>
29</div>
30
31
32<p><em>API Level:</em>&nbsp;<strong>{@sdkPlatformApiLevel}</strong></p>
33
34<p>Android 4.0 (Ice Cream Sandwich) is a major platform release that adds new
35capabilities for users and developers. The sections below provide an overview
36of the new features and developer APIs.</p>
37
38<p>For developers, the Android {@sdkPlatformVersion} platform is available as a
39downloadable component for the Android SDK. The downloadable platform includes
40an Android library and system image, as well as a set of emulator skins and
41more. The downloadable platform includes no external libraries.</p>
42
43<p>To start developing or testing against Android {@sdkPlatformVersion},
44use the Android SDK Manager to download the platform into your SDK. For more
45information, see <a href="{@docRoot}sdk/adding-components.html">Adding SDK
46Components</a>. If you are new to Android, <a
47href="{@docRoot}sdk/index.html">download the SDK Starter Package</a> first.</p>
48
Scott Main1d6f70c2011-10-06 22:57:25 -070049<p class="note"><strong>Reminder:</strong> If you've already published an
50Android application, please test your application on Android {@sdkPlatformVersion} as
51soon as possible to be sure your application provides the best
52experience possible on the latest Android-powered devices.</p>
53
Scott Maine1e9e932011-10-13 23:36:19 -070054<p>For a high-level introduction to the new user and developer features in Android 4.0, see the
55<a href="http://developer.android.com/sdk/android-4.0-highlights.html">Platform Highlights</a>.</p>
56
Scott Main1d6f70c2011-10-06 22:57:25 -070057
58<h2 id="relnotes">Revisions</h2>
59
60<p>To determine what revision of the Android {@sdkPlatformVersion} platform you
61have installed, refer to the "Installed Packages" listing in the Android SDK Manager.</p>
62
63
64<div class="toggle-content opened" style="padding-left:1em;">
65
66 <p><a href="#" onclick="return toggleContent(this)">
67 <img src="{@docRoot}assets/images/triangle-opened.png"
68class="toggle-content-img" alt="" />
69 Android {@sdkPlatformVersion}, Revision 1</a> <em>(October 2011)</em>
70 </a></p>
71
72 <div class="toggle-content-toggleme" style="padding-left:2em;">
73
74<dl>
Scott Maine1e9e932011-10-13 23:36:19 -070075<dt>Initial release. SDK Tools r14 or higher is recommended.</dt>
Scott Main1d6f70c2011-10-06 22:57:25 -070076</dl>
77
78 </div>
79</div>
80
81
82<h2 id="api">API Overview</h2>
83
84<p>The sections below provide a technical overview of new APIs in Android 4.0.</p>
85
86<div class="toggle-content closed" style="padding-left:1em;">
87
88 <p><a href="#" onclick="return toggleContent(this)">
89 <img src="{@docRoot}assets/images/triangle-closed.png"
90class="toggle-content-img" alt="" />
91 <strong>Table of Contents</strong>
92 </a></p>
93
94 <div class="toggle-content-toggleme" style="padding-left:2em;">
95 <ol class="toc" style="margin-left:-1em">
Scott Maine1e9e932011-10-13 23:36:19 -070096 <li><a href="#Contacts">Contact Provider</a></li>
97 <li><a href="#Calendar">Calendar Provider</a></li>
98 <li><a href="#Voicemail">Voicemail Provider</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -070099 <li><a href="#Camera">Camera</a></li>
100 <li><a href="#Multimedia">Multimedia</a></li>
101 <li><a href="#Bluetooth">Bluetooth</a></li>
102 <li><a href="#AndroidBeam">Android Beam (NDEF Push with NFC)</a></li>
103 <li><a href="#P2pWiFi">Peer-to-peer Wi-Fi</a></li>
104 <li><a href="#NetworkData">Network Data</a></li>
Scott Maine1e9e932011-10-13 23:36:19 -0700105 <li><a href="#RenderScript">RenderScript</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700106 <li><a href="#A11y">Accessibility</a></li>
107 <li><a href="#Enterprise">Enterprise</a></li>
Scott Maine1e9e932011-10-13 23:36:19 -0700108 <li><a href="#Sensors">Device Sensors</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700109 <li><a href="#TTS">Text-to-speech Engines</a></li>
Scott Maine1e9e932011-10-13 23:36:19 -0700110 <li><a href="#SpellChecker">Spell Checker Services</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700111 <li><a href="#ActionBar">Action Bar</a></li>
112 <li><a href="#UI">User Interface and Views</a></li>
113 <li><a href="#Properties">Properties</a></li>
114 <li><a href="#HwAccel">Hardware Acceleration</a></li>
115 <li><a href="#Jni">JNI Changes</a></li>
116 <li><a href="#WebKit">WebKit</a></li>
117 <li><a href="#Permissions">Permissions</a></li>
118 <li><a href="#DeviceFeatures">Device Features</a></li>
119 </ol>
120 </div>
121</div>
122
123
124
125
126
Scott Maine1e9e932011-10-13 23:36:19 -0700127<h3 id="Contacts">Contact Provider</h3>
Scott Main1d6f70c2011-10-06 22:57:25 -0700128
Scott Maine1e9e932011-10-13 23:36:19 -0700129<p>The contact APIs that are defined by the {@link android.provider.ContactsContract} provider have
130been extended to support new features such as a personal profile for the device owner, high
131resolution contact photos, and the ability for users to invite individual contacts to social
132networks that are installed on the device.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700133
134
135<h4>User Profile</h4>
136
137<p>Android now includes a personal profile that represents the device owner, as defined by the
Scott Maine1e9e932011-10-13 23:36:19 -0700138{@link android.provider.ContactsContract.Profile} table. Social apps that maintain a user identity
139can contribute to the user's profile data by creating a new {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700140android.provider.ContactsContract.RawContacts} entry within the {@link
141android.provider.ContactsContract.Profile}. That is, raw contacts that represent the device user do
142not belong in the traditional raw contacts table defined by the {@link
143android.provider.ContactsContract.RawContacts} Uri; instead, you must add a profile raw contact in
144the table at {@link android.provider.ContactsContract.Profile#CONTENT_RAW_CONTACTS_URI}. Raw
Scott Maine1e9e932011-10-13 23:36:19 -0700145contacts in this table are then aggregated into the single user-visible profile labeled "Me".</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700146
147<p>Adding a new raw contact for the profile requires the {@link
148android.Manifest.permission#WRITE_PROFILE} permission. Likewise, in order to read from the profile
149table, you must request the {@link android.Manifest.permission#READ_PROFILE} permission. However,
Scott Maine1e9e932011-10-13 23:36:19 -0700150most apps should need to read the user profile, even when contributing data to the
151profile. Reading the user profile is a sensitive permission and you should expect users to be
152skeptical of apps that request it.</p>
153
Scott Main1d6f70c2011-10-06 22:57:25 -0700154
155<h4>Large photos</h4>
156
157<p>Android now supports high resolution photos for contacts. Now, when you push a photo into a
Scott Maine1e9e932011-10-13 23:36:19 -0700158contact record, the system processes it into both a 96x96 thumbnail (as it has previously) and a
159256x256 "display photo" that's stored in a new file-based photo store (the exact dimensions that the
160system chooses may vary in the future). You can add a large photo to a contact by putting a large
161photo in the usual {@link android.provider.ContactsContract.CommonDataKinds.Photo#PHOTO} column of a
162data row, which the system will then process into the appropriate thumbnail and display photo
163records.</p>
164
Scott Main1d6f70c2011-10-06 22:57:25 -0700165
166<h4>Invite Intent</h4>
167
Scott Maine1e9e932011-10-13 23:36:19 -0700168<p>The {@link android.provider.ContactsContract.Intents#INVITE_CONTACT} intent action allows an app
169to invoke an action that indicates the user wants to add a contact to a social network. The app
170receiving the app uses it to invite the specified contact to that
171social network. Most apps will be on the receiving-end of this operation. For example, the
172built-in People app invokes the invite intent when the user selects "Add connection" for a specific
173social app that's listed in a person's contact details.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700174
Scott Maine1e9e932011-10-13 23:36:19 -0700175<p>To make your app visible as in the "Add connection" list, your app must provide a sync adapter to
176sync contact information from your social network. You must then indicate to the system that your
177app responds to the {@link android.provider.ContactsContract.Intents#INVITE_CONTACT} intent by
178adding the {@code inviteContactActivity} attribute to your app’s sync configuration file, with a
179fully-qualified name of the activity that the system should start when sending the invite intent.
180The activity that starts can then retrieve the URI for the contact in question from the intent’s
181data and perform the necessary work to invite that contact to the network or add the person to the
182user’s connections.</p>
183
184<p>See the <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html">Sample Sync
185Adapter</a> app for an example (specifically, see the <a
186href="{@docRoot}resources/samples/SampleSyncAdapter/res/xml-v14/contacts.html">contacts.xml</a>
187file).</p>
188
Scott Main1d6f70c2011-10-06 22:57:25 -0700189
190<h4>Contact Usage Feedback</h4>
191
192<p>The new {@link android.provider.ContactsContract.DataUsageFeedback} APIs allow you to help track
193how often the user uses particular methods of contacting people, such as how often the user uses
194each phone number or e-mail address. This information helps improve the ranking for each contact
Scott Maine1e9e932011-10-13 23:36:19 -0700195method associated with each person and provide better suggestions for contacting each person.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700196
197
198
199
200
Scott Maine1e9e932011-10-13 23:36:19 -0700201<h3 id="Calendar">Calendar Provider</h3>
Scott Main1d6f70c2011-10-06 22:57:25 -0700202
Scott Maine1e9e932011-10-13 23:36:19 -0700203<p>The new calendar APIs allow you to access and modify the user’s calendars and events using the
204Calendar Provider. You can read, add, modify and delete calendars, events, attendees, reminders and
205alerts.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700206
Scott Maine1e9e932011-10-13 23:36:19 -0700207<p>A variety of apps and widgets can use these APIs to read and modify calendar events. However,
208some of the most compelling use cases are sync adapters that synchronize the user's calendar from
209other calendar services with the Calendar Provider, in order to offer a unified location for
210all the user's events. Google Calendar, for example, uses a sync adapter to synchronize Google
211Calendar events with the Calendar Provider, which can then be viewed with Android's built-in
212Calendar app.</p>
213
214<p>The data model for calendars and event-related information in the Calendar Provider is
215defined by {@link android.provider.CalendarContract}. All the user’s calendar data is stored in a
216number of tables defined by various subclasses of {@link android.provider.CalendarContract}:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700217
218<ul>
219<li>The {@link android.provider.CalendarContract.Calendars} table holds the calendar-specific
220information. Each row in this table contains the details for a single calendar, such as the name,
221color, sync information, and so on.</li>
222
223<li>The {@link android.provider.CalendarContract.Events} table holds event-specific information.
Scott Maine1e9e932011-10-13 23:36:19 -0700224Each row in this table contains the information for a single event, such as the
225event title, location, start time, end time, and so on. The event can occur one time or recur
226multiple times. Attendees, reminders, and extended properties are stored in separate tables and
227use the event’s {@code _ID} to link them with the event.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700228
229<li>The {@link android.provider.CalendarContract.Instances} table holds the start and end time for
230occurrences of an event. Each row in this table represents a single occurrence. For one-time events
231there is a one-to-one mapping of instances to events. For recurring events, multiple rows are
232automatically generated to correspond to the multiple occurrences of that event.</li>
233
234<li>The {@link android.provider.CalendarContract.Attendees} table holds the event attendee or guest
235information. Each row represents a single guest of an event. It specifies the type of guest the
Scott Maine1e9e932011-10-13 23:36:19 -0700236person is and the person’s response for the event.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700237
238<li>The {@link android.provider.CalendarContract.Reminders} table holds the alert/notification data.
239Each row represents a single alert for an event. An event can have multiple reminders. The number of
Scott Maine1e9e932011-10-13 23:36:19 -0700240reminders per event is specified in {@code MAX_REMINDERS}, which is set by the sync adapter that
241owns the given calendar. Reminders are specified in number-of-minutes before the event is
242scheduled and specify an alarm method such as to use an alert, email, or SMS to remind
243the user.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700244
245<li>The {@link android.provider.CalendarContract.ExtendedProperties} table hold opaque data fields
Scott Maine1e9e932011-10-13 23:36:19 -0700246used by the sync adapter. The provider takes no action with items in this table except to delete
247them when their related events are deleted.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700248</ul>
249
Scott Maine1e9e932011-10-13 23:36:19 -0700250<p>To access a user’s calendar data with the Calendar Provider, your application must request
251the {@link android.Manifest.permission#READ_CALENDAR} permission (for read access) and
252{@link android.Manifest.permission#WRITE_CALENDAR} (for write access).</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700253
Scott Main1d6f70c2011-10-06 22:57:25 -0700254
Scott Maine1e9e932011-10-13 23:36:19 -0700255<h4>Event intent</h4>
256
257<p>If all you want to do is add an event to the user’s calendar, you can use an
258{@link android.content.Intent#ACTION_INSERT} intent with a {@code "vnd.android.cursor.item/event"}
259MIME type to start an activity in the Calendar app that creates new events. Using the intent does
260not require any permission and you can specify event details with the following extras:</p>
261
262<ul>
263 <li>{@link android.provider.CalendarContract.EventsColumns#TITLE Events.TITLE}: Name for the
264event</li>
265 <li>{@link
266android.provider.CalendarContract#EXTRA_EVENT_BEGIN_TIME CalendarContract.EXTRA_EVENT_BEGIN_TIME}:
267Event begin time in milliseconds from the
268epoch</li>
269 <li>{@link
270android.provider.CalendarContract#EXTRA_EVENT_END_TIME CalendarContract.EXTRA_EVENT_END_TIME}: Event
271end time in milliseconds from the epoch</li>
272 <li>{@link android.provider.CalendarContract.EventsColumns#EVENT_LOCATION Events.EVENT_LOCATION}:
273Location of the event</li>
274 <li>{@link android.provider.CalendarContract.EventsColumns#DESCRIPTION Events.DESCRIPTION}: Event
275description</li>
276 <li>{@link android.content.Intent#EXTRA_EMAIL Intent.EXTRA_EMAIL}: Email addresses of those to
277invite</li>
278 <li>{@link android.provider.CalendarContract.EventsColumns#RRULE Events.RRULE}: The recurrence
279rule for the event</li>
280 <li>{@link android.provider.CalendarContract.EventsColumns#ACCESS_LEVEL Events.ACCESS_LEVEL}:
281Whether the event is private or public</li>
282 <li>{@link android.provider.CalendarContract.EventsColumns#AVAILABILITY Events.AVAILABILITY}:
283Whether the time period of this event allows for other events to be scheduled at the same time</li>
284</ul>
285
286
287
288
289<h3 id="Voicemail">Voicemail Provider</h3>
290
291<p>The new voicemail APIs allows applications to add voicemails to a content provider on the device.
292Because the APIs currently do not allow third party apps to read all the voicemails from the system,
293the only third-party apps that should use the voicemail APIs are those that have voicemail to
294deliver to the user. For instance, it’s possible that a user has multiple voicemail sources, such as
295one provided by the phone’s service provider and others from VoIP or other alternative voice
296services. These apps can use the APIs to add their voicemails to the system for quick playback. The
297built-in Phone application presents all voicemails from the Voicemail Provider with a single list.
298Although the system’s Phone application is the only application that can read all the voicemails,
299each application that provides voicemails can read those that it has added to the system (but cannot
300read voicemails from other services).</p>
301
302<p>The {@link android.provider.VoicemailContract} class defines the content provider for the
303voicemail APIs. The subclasses {@link android.provider.VoicemailContract.Voicemails} and {@link
304android.provider.VoicemailContract.Status} provide tables in which the Voicemail Providers can
305insert voicemail data for storage on the device. For an example of a voicemail provider app, see the
306<a href=”{@docRoot}resources/samples/VoicemailProviderDemo/index.html”>Voicemail Provider
307Demo</a>.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700308
309
310
311
312<h3 id="Camera">Camera</h3>
313
Scott Maine1e9e932011-10-13 23:36:19 -0700314<p>The {@link android.hardware.Camera} class now includes APIs for detecting faces and controlling
315focus and metering areas.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700316
Scott Main1d6f70c2011-10-06 22:57:25 -0700317
Scott Maine1e9e932011-10-13 23:36:19 -0700318<h4>Face detection</h4>
319
320<p>Camera apps can now enhance their abilities with Android’s face detection APIs, which not
321only detect the face of a subject, but also specific facial features, such as the eyes and mouth.
322</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700323
324<p>To detect faces in your camera application, you must register a {@link
325android.hardware.Camera.FaceDetectionListener} by calling {@link
326android.hardware.Camera#setFaceDetectionListener setFaceDetectionListener()}. You can then start
327your camera surface and start detecting faces by calling {@link
328android.hardware.Camera#startFaceDetection}.</p>
329
Scott Maine1e9e932011-10-13 23:36:19 -0700330<p>When the system detects one or more faces in the camera scene, it calls the {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700331android.hardware.Camera.FaceDetectionListener#onFaceDetection onFaceDetection()} callback in your
332implementation of {@link android.hardware.Camera.FaceDetectionListener}, including an array of
333{@link android.hardware.Camera.Face} objects.</p>
334
335<p>An instance of the {@link android.hardware.Camera.Face} class provides various information about
Scott Maine1e9e932011-10-13 23:36:19 -0700336the face detected, including:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700337<ul>
338<li>A {@link android.graphics.Rect} that specifies the bounds of the face, relative to the camera's
339current field of view</li>
340<li>An integer betwen 0 and 100 that indicates how confident the system is that the object is a
Scott Maine1e9e932011-10-13 23:36:19 -0700341human face</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700342<li>A unique ID so you can track multiple faces</li>
343<li>Several {@link android.graphics.Point} objects that indicate where the eyes and mouth are
344located</li>
345</ul>
346
Scott Maine1e9e932011-10-13 23:36:19 -0700347
348<h4>Focus and metering areas</h4>
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700349
Scott Maine1e9e932011-10-13 23:36:19 -0700350<p>Camera apps can now control the areas that the camera uses for focus and for metering white
Scott Main1d6f70c2011-10-06 22:57:25 -0700351balance
Scott Maine1e9e932011-10-13 23:36:19 -0700352and auto-exposure. Both features use the new {@link android.hardware.Camera.Area} class to specify
353the region of the camera’s current view that should be focused or metered. An instance of the {@link
354android.hardware.Camera.Area} class defines the bounds of the area with a {@link
355android.graphics.Rect} and the area's weight&mdash;representing the level of importance of that
356area, relative to other areas in consideration&mdash;with an integer.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700357
358<p>Before setting either a focus area or metering area, you should first call {@link
359android.hardware.Camera.Parameters#getMaxNumFocusAreas} or {@link
360android.hardware.Camera.Parameters#getMaxNumMeteringAreas}, respectively. If these return zero, then
Scott Maine1e9e932011-10-13 23:36:19 -0700361the device does not support the corresponding feature.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700362
363<p>To specify the focus or metering areas to use, simply call {@link
364android.hardware.Camera.Parameters#setFocusAreas setFocusAreas()} or {@link
365android.hardware.Camera.Parameters#setFocusAreas setMeteringAreas()}. Each take a {@link
366java.util.List} of {@link android.hardware.Camera.Area} objects that indicate the areas to consider
367for focus or metering. For example, you might implement a feature that allows the user to set the
368focus area by touching an area of the preview, which you then translate to an {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700369android.hardware.Camera.Area} object and request that the camera focus on that area of the scene.
370The focus or exposure in that area will continually update as the scene in the area changes.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700371
372
Scott Maine1e9e932011-10-13 23:36:19 -0700373<h4>Other camera features</h4>
374
Scott Main1d6f70c2011-10-06 22:57:25 -0700375<ul>
Scott Maine1e9e932011-10-13 23:36:19 -0700376<li>While recording video, you can now call {@link android.hardware.Camera#takePicture
377takePicture()} to save a photo without interrupting the video session. Before doing so, you should
378call {@link android.hardware.Camera.Parameters#isVideoSnapshotSupported} to be sure the hardware
379supports it.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700380
381<li>Lock auto exposure and white balance with {@link
382android.hardware.Camera.Parameters#setAutoExposureLock setAutoExposureLock()} and {@link
383android.hardware.Camera.Parameters#setAutoWhiteBalanceLock setAutoWhiteBalanceLock()}, to prevent
384these properties from changing.</li>
385</ul>
386
Scott Maine1e9e932011-10-13 23:36:19 -0700387
388<h4>Camera broadcast intents</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700389
390<ul>
Scott Maine1e9e932011-10-13 23:36:19 -0700391<li>{@link android.hardware.Camera#ACTION_NEW_PICTURE Camera.ACTION_NEW_PICTURE}:
392This indicates that the user has captured a new photo. The built-in Camera app invokes this
Scott Main1d6f70c2011-10-06 22:57:25 -0700393broadcast after a photo is captured and third-party camera apps should also broadcast this intent
394after capturing a photo.</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700395<li>{@link android.hardware.Camera#ACTION_NEW_VIDEO Camera.ACTION_NEW_VIDEO}:
396This indicates that the user has captured a new video. The built-in Camera app invokes this
Scott Main1d6f70c2011-10-06 22:57:25 -0700397broadcast after a video is recorded and third-party camera apps should also broadcast this intent
398after capturing a video.</li>
399</ul>
400
Scott Main1d6f70c2011-10-06 22:57:25 -0700401
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700402
403
404
Scott Main1d6f70c2011-10-06 22:57:25 -0700405<h3 id="Multimedia">Multimedia</h3>
406
407<p>Android 4.0 adds several new APIs for applications that interact with media such as photos,
Scott Maine1e9e932011-10-13 23:36:19 -0700408videos, and music.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700409
410
Scott Maine1e9e932011-10-13 23:36:19 -0700411<h4>Media player</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700412
413<ul>
Scott Maine1e9e932011-10-13 23:36:19 -0700414<li>Streaming online media from {@link android.media.MediaPlayer} now requires the {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700415android.Manifest.permission#INTERNET} permission. If you use {@link android.media.MediaPlayer} to
Scott Maine1e9e932011-10-13 23:36:19 -0700416play content from the Internet, be sure to add the {@link android.Manifest.permission#INTERNET}
417permission to your manifest or else your media playback will not work beginning with Android
4184.0.</li>
419
Scott Main1d6f70c2011-10-06 22:57:25 -0700420<li>{@link android.media.MediaPlayer#setSurface(Surface) setSurface()} allows you define a {@link
421android.view.Surface} to behave as the video sink.</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700422
Scott Main1d6f70c2011-10-06 22:57:25 -0700423<li>{@link android.media.MediaPlayer#setDataSource(Context,Uri,Map) setDataSource()} allows you to
424send additional HTTP headers with your request, which can be useful for HTTP(S) live streaming</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700425
Scott Main1d6f70c2011-10-06 22:57:25 -0700426<li>HTTP(S) live streaming now respects HTTP cookies across requests</li>
427</ul>
428
Scott Maine1e9e932011-10-13 23:36:19 -0700429
430<h4>Media types</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700431
432<p>Android 4.0 adds support for:</p>
433<ul>
434<li>HTTP/HTTPS live streaming protocol version 3 </li>
435<li>ADTS raw AAC audio encoding</li>
436<li>WEBP images</li>
437<li>Matroska video</li>
438</ul>
439<p>For more info, see <a href=”{@docRoot}guide/appendix/media-formats.html”>Supported Media
440Formats</a>.</p>
441
442
Scott Maine1e9e932011-10-13 23:36:19 -0700443
444<h4>Remote control client</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700445
446<p>The new {@link android.media.RemoteControlClient} allows media players to enable playback
Scott Maine1e9e932011-10-13 23:36:19 -0700447controls from remote control clients such as the device lock screen. Media players can also expose
Scott Main1d6f70c2011-10-06 22:57:25 -0700448information about the media currently playing for display on the remote control, such as track
449information and album art.</p>
450
451<p>To enable remote control clients for your media player, instantiate a {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700452android.media.RemoteControlClient} with its constructor, passing it a {@link
453android.app.PendingIntent} that broadcasts {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700454android.content.Intent#ACTION_MEDIA_BUTTON}. The intent must also declare the explicit {@link
455android.content.BroadcastReceiver} component in your app that handles the {@link
456android.content.Intent#ACTION_MEDIA_BUTTON} event.</p>
457
458<p>To declare which media control inputs your player can handle, you must call {@link
459android.media.RemoteControlClient#setTransportControlFlags setTransportControlFlags()} on your
460{@link android.media.RemoteControlClient}, passing a set of {@code FLAG_KEY_MEDIA_*} flags, such as
461{@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PREVIOUS} and {@link
462android.media.RemoteControlClient#FLAG_KEY_MEDIA_NEXT}.</p>
463
464<p>You must then register your {@link android.media.RemoteControlClient} by passing it to {@link
465android.media.AudioManager#registerRemoteControlClient MediaManager.registerRemoteControlClient()}.
466Once registered, the broadcast receiver you declared when you instantiated the {@link
467android.media.RemoteControlClient} will receive {@link android.content.Intent#ACTION_MEDIA_BUTTON}
468events when a button is pressed from a remote control. The intent you receive includes the {@link
469android.view.KeyEvent} for the media key pressed, which you can retrieve from the intent with {@link
470android.content.Intent#getParcelableExtra getParcelableExtra(Intent.EXTRA_KEY_EVENT)}.</p>
471
472<p>To display information on the remote control about the media playing, call {@link
473android.media.RemoteControlClient#editMetadata editMetaData()} and add metadata to the returned
474{@link android.media.RemoteControlClient.MetadataEditor}. You can supply a bitmap for media artwork,
475numerical information such as elapsed time, and text information such as the track title. For
476information on available keys see the {@code METADATA_KEY_*} flags in {@link
477android.media.MediaMetadataRetriever}.</p>
478
479<p>For a sample implementation, see the <a
480href=”{@docRoot}resources/samples/RandomMusicPlayer/index.html”>Random Music Player</a>, which
Scott Maine1e9e932011-10-13 23:36:19 -0700481provides compatibility logic such that it enables the remote control client on Android 4.0
482devices while continuing to support devices back to Android 2.1.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700483
484
485<h4>Media Effects</h4>
486
487<p>A new media effects framework allows you to apply a variety of visual effects to images and
Scott Maine1e9e932011-10-13 23:36:19 -0700488videos. The system performs all effects processing on the GPU to obtain maximum performance.
489New applications for Android 4.0 such as Google Talk and the Gallery editor make use of the
490effects API to apply real-time effects to video and photos.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700491
492<p>For maximum performance, effects are applied directly to OpenGL textures, so your application
Scott Maine1e9e932011-10-13 23:36:19 -0700493must have a valid OpenGL context before it can use the effects APIs. The textures to which you apply
Scott Main1d6f70c2011-10-06 22:57:25 -0700494effects may be from bitmaps, videos or even the camera. However, there are certain restrictions that
495textures must meet:</p>
496<ol>
497<li>They must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture image</li>
498<li>They must contain at least one mipmap level</li>
499</ol>
500
501<p>An {@link android.media.effect.Effect} object defines a single media effect that you can apply to
Scott Maine1e9e932011-10-13 23:36:19 -0700502an image frame. The basic workflow to create an {@link android.media.effect.Effect} is:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700503
504<ol>
505<li>Call {@link android.media.effect.EffectContext#createWithCurrentGlContext
506EffectContext.createWithCurrentGlContext()} from your OpenGL ES 2.0 context.</li>
507<li>Use the returned {@link android.media.effect.EffectContext} to call {@link
508android.media.effect.EffectContext#getFactory EffectContext.getFactory()}, which returns an instance
509of {@link android.media.effect.EffectFactory}.</li>
510<li>Call {@link android.media.effect.EffectFactory#createEffect createEffect()}, passing it an
Scott Maine1e9e932011-10-13 23:36:19 -0700511effect name from @link android.media.effect.EffectFactory}, such as {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700512android.media.effect.EffectFactory#EFFECT_FISHEYE} or {@link
513android.media.effect.EffectFactory#EFFECT_VIGNETTE}.</li>
514</ol>
515
516<p>Not all devices support all effects, so you must first check if the desired effect is supported
Scott Maine1e9e932011-10-13 23:36:19 -0700517by calling {@link android.media.effect.EffectFactory#isEffectSupported isEffectSupported()}.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700518
Scott Maine1e9e932011-10-13 23:36:19 -0700519<p>You can adjust an effect’s parameters by calling {@link android.media.effect.Effect#setParameter
Scott Main1d6f70c2011-10-06 22:57:25 -0700520setParameter()} and passing a parameter name and parameter value. Each type of effect accepts
521different parameters, which are documented with the effect name. For example, {@link
522android.media.effect.EffectFactory#EFFECT_FISHEYE} has one parameter for the {@code scale} of the
523distortion.</p>
524
525<p>To apply an effect on a texture, call {@link android.media.effect.Effect#apply apply()} on the
526{@link
527android.media.effect.Effect} and pass in the input texture, it’s width and height, and the output
528texture. The input texture must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture
529image (usually done by calling the {@link android.opengl.GLES20#glTexImage2D glTexImage2D()}
530function). You may provide multiple mipmap levels. If the output texture has not been bound to a
531texture image, it will be automatically bound by the effect as a {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700532android.opengl.GLES20#GL_TEXTURE_2D} and with one mipmap level (0), which will have the same
533size as the input.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700534
535
536
537
538
539
540
541<h3 id="Bluetooth">Bluetooth</h3>
542
543<p>Android now supports Bluetooth Health Profile devices, so you can create applications that use
544Bluetooth to communicate with health devices that support Bluetooth, such as heart-rate monitors,
545blood meters, thermometers, and scales.</p>
546
547<p>Similar to regular headset and A2DP profile devices, you must call {@link
548android.bluetooth.BluetoothAdapter#getProfileProxy getProfileProxy()} with a {@link
549android.bluetooth.BluetoothProfile.ServiceListener} and the {@link
550android.bluetooth.BluetoothProfile#HEALTH} profile type to establish a connection with the profile
551proxy object.</p>
552
Scott Maine1e9e932011-10-13 23:36:19 -0700553<p>Once you’ve acquired the Health Profile proxy (the {@link android.bluetooth.BluetoothHealth}
Scott Main1d6f70c2011-10-06 22:57:25 -0700554object), connecting to and communicating with paired health devices involves the following new
555Bluetooth classes:</p>
556<ul>
557<li>{@link android.bluetooth.BluetoothHealthCallback}: You must extend this class and implement the
558callback methods to receive updates about changes in the application’s registration state and
559Bluetooth channel state.</li>
560<li>{@link android.bluetooth.BluetoothHealthAppConfiguration}: During callbacks to your {@link
561android.bluetooth.BluetoothHealthCallback}, you’ll receive an instance of this object, which
562provides configuration information about the available Bluetooth health device, which you must use
563to perform various operations such as initiate and terminate connections with the {@link
564android.bluetooth.BluetoothHealth} APIs.</li>
565</ul>
566
Scott Maine1e9e932011-10-13 23:36:19 -0700567<p>For more information about using the Bluetooth Health Profile, see the documentation for {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700568android.bluetooth.BluetoothHealth}.</p>
569
570
Scott Maine1e9e932011-10-13 23:36:19 -0700571
Scott Main1d6f70c2011-10-06 22:57:25 -0700572<h3 id="AndroidBeam">Android Beam (NDEF Push with NFC)</h3>
573
Scott Maine1e9e932011-10-13 23:36:19 -0700574<p>Android Beam is a new NFC feature that allows you to send NDEF messages from one device to
575another (a process also known as “NDEF Push”). The data transfer is initiated when two
Scott Main1d6f70c2011-10-06 22:57:25 -0700576Android-powered devices that support Android Beam are in close proximity (about 4 cm), usually with
577their backs touching. The data inside the NDEF message can contain any data that you wish to share
578between devices. For example, the People app shares contacts, YouTube shares videos, and Browser
579shares URLs using Android Beam.</p>
580
581<p>To transmit data between devices using Android Beam, you need to create an {@link
582android.nfc.NdefMessage} that contains the information you want to share while your activity is in
Scott Maine1e9e932011-10-13 23:36:19 -0700583the foreground. You must then pass the {@link android.nfc.NdefMessage} to the system in one of two
584ways:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700585
586<ul>
Scott Maine1e9e932011-10-13 23:36:19 -0700587<li>Define a single {@link android.nfc.NdefMessage} to push while in the activity:
Scott Main1d6f70c2011-10-06 22:57:25 -0700588<p>Call {@link android.nfc.NfcAdapter#setNdefPushMessage setNdefPushMessage()} at any time to set
Scott Maine1e9e932011-10-13 23:36:19 -0700589the message you want to send. For instance, you might call this method and pass it your {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700590android.nfc.NdefMessage} during your activity’s {@link android.app.Activity#onCreate onCreate()}
Scott Maine1e9e932011-10-13 23:36:19 -0700591method. Then, whenever Android Beam is activated with another device while the activity is in the
592foreground, the system sends the {@link android.nfc.NdefMessage} to the other device.</p></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700593
Scott Maine1e9e932011-10-13 23:36:19 -0700594<li>Define the {@link android.nfc.NdefMessage} to push at the time that Android Beam is initiated:
595<p>Implement {@link android.nfc.NfcAdapter.CreateNdefMessageCallback}, in which your
596implementation of the {@link
597android.nfc.NfcAdapter.CreateNdefMessageCallback#createNdefMessage createNdefMessage()}
Scott Main1d6f70c2011-10-06 22:57:25 -0700598method returns the {@link android.nfc.NdefMessage} you want to send. Then pass the {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700599android.nfc.NfcAdapter.CreateNdefMessageCallback} implementation to {@link
600android.nfc.NfcAdapter#setNdefPushMessageCallback setNdefPushMessageCallback()}.</p>
601<p>In this case, when Android Beam is activated with another device while your activity is in the
602foreground, the system calls {@link
603android.nfc.NfcAdapter.CreateNdefMessageCallback#createNdefMessage createNdefMessage()} to retrieve
604the {@link android.nfc.NdefMessage} you want to send. This allows you to define the {@link
605android.nfc.NdefMessage} to deliver only once Android Beam is initiated, in case the contents
606of the message might vary throughout the life of the activity.</p></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700607</ul>
608
609<p>In case you want to run some specific code once the system has successfully delivered your NDEF
610message to the other device, you can implement {@link
611android.nfc.NfcAdapter.OnNdefPushCompleteCallback} and set it with {@link
612android.nfc.NfcAdapter#setOnNdefPushCompleteCallback setNdefPushCompleteCallback()}. The system will
613then call {@link android.nfc.NfcAdapter.OnNdefPushCompleteCallback#onNdefPushComplete
614onNdefPushComplete()} when the message is delivered.</p>
615
616<p>On the receiving device, the system dispatches NDEF Push messages in a similar way to regular NFC
617tags. The system invokes an intent with the {@link android.nfc.NfcAdapter#ACTION_NDEF_DISCOVERED}
618action to start an activity, with either a URL or a MIME type set according to the first {@link
619android.nfc.NdefRecord} in the {@link android.nfc.NdefMessage}. For the activity you want to
Scott Maine1e9e932011-10-13 23:36:19 -0700620respond, you can declare intent filters for the URLs or MIME types your app cares about. For more
Scott Main1d6f70c2011-10-06 22:57:25 -0700621information about Tag Dispatch see the <a
622href=”{@docRoot}guide/topics/nfc/index.html#dispatch”>NFC</a> developer guide.</p>
623
624<p>If you want your {@link android.nfc.NdefMessage} to carry a URI, you can now use the convenience
625method {@link android.nfc.NdefRecord#createUri createUri} to construct a new {@link
626android.nfc.NdefRecord} based on either a string or a {@link android.net.Uri} object. If the URI is
627a special format that you want your application to also receive during an Android Beam event, you
628should create an intent filter for your activity using the same URI scheme in order to receive the
629incoming NDEF message.</p>
630
Scott Maine1e9e932011-10-13 23:36:19 -0700631<p>You should also pass an “Android application record” with your {@link android.nfc.NdefMessage} in
632order to guarantee that your application handles the incoming NDEF message, even if other
633applications filter for the same intent action. You can create an Android application record by
634calling {@link android.nfc.NdefRecord#createApplicationRecord createApplicationRecord()}, passing it
635your application’s package name. When the other device receives the NDEF message with the
636application record and multiple applications contain activities that handle the specified intent,
637the system always delivers the message to the activity in your application (based on the matching
638application record). If the target device does not currently have your application installed, the
639system uses the Android application record to launch Android Market and take the user to the
640application in order to install it.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700641
642<p>If your application doesn’t use NFC APIs to perform NDEF Push messaging, then Android provides a
643default behavior: When your application is in the foreground on one device and Android Beam is
644invoked with another Android-powered device, then the other device receives an NDEF message with an
645Android application record that identifies your application. If the receiving device has the
646application installed, the system launches it; if it’s not installed, Android Market opens and takes
Scott Maine1e9e932011-10-13 23:36:19 -0700647the user to your application in order to install it.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700648
Scott Maine1e9e932011-10-13 23:36:19 -0700649<p>For some example code, see the <a
650href="{@docRoot}resources/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.html">Android
651Beam Demo</a> sample app.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700652
653
654
655
656<h3 id="P2pWiFi">Peer-to-peer Wi-Fi</h3>
657
Scott Maine1e9e932011-10-13 23:36:19 -0700658<p>Android now supports Wi-Fi Direct for peer-to-peer (P2P) connections between Android-powered
Scott Main1d6f70c2011-10-06 22:57:25 -0700659devices and other device types without a hotspot or Internet connection. The Android framework
660provides a set of Wi-Fi P2P APIs that allow you to discover and connect to other devices when each
Scott Maine1e9e932011-10-13 23:36:19 -0700661device supports Wi-Fi Direct, then communicate over a speedy connection across distances much longer
662than a Bluetooth connection.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700663
664<p>A new package, {@link android.net.wifi.p2p}, contains all the APIs for performing peer-to-peer
665connections with Wi-Fi. The primary class you need to work with is {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700666android.net.wifi.p2p.WifiP2pManager}, which you can acquire by calling {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700667android.app.Activity#getSystemService getSystemService(WIFI_P2P_SERVICE)}. The {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700668android.net.wifi.p2p.WifiP2pManager} includes APIs that allow you to:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700669<ul>
670<li>Initialize your application for P2P connections by calling {@link
671android.net.wifi.p2p.WifiP2pManager#initialize initialize()}</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700672
Scott Main1d6f70c2011-10-06 22:57:25 -0700673<li>Discover nearby devices by calling {@link android.net.wifi.p2p.WifiP2pManager#discoverPeers
674discoverPeers()}</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700675
Scott Main1d6f70c2011-10-06 22:57:25 -0700676<li>Start a P2P connection by calling {@link android.net.wifi.p2p.WifiP2pManager#connect
677connect()}</li>
678<li>And more</li>
679</ul>
680
681<p>Several other interfaces and classes are necessary as well, such as:</p>
682<ul>
683<li>The {@link android.net.wifi.p2p.WifiP2pManager.ActionListener} interface allows you to receive
684callbacks when an operation such as discovering peers or connecting to them succeeds or fails.</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700685
Scott Main1d6f70c2011-10-06 22:57:25 -0700686<li>{@link android.net.wifi.p2p.WifiP2pManager.PeerListListener} interface allows you to receive
687information about discovered peers. The callback provides a {@link
688android.net.wifi.p2p.WifiP2pDeviceList}, from which you can retrieve a {@link
689android.net.wifi.p2p.WifiP2pDevice} object for each device within range and get information such as
690the device name, address, device type, the WPS configurations the device supports, and more.</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700691
Scott Main1d6f70c2011-10-06 22:57:25 -0700692<li>The {@link android.net.wifi.p2p.WifiP2pManager.GroupInfoListener} interface allows you to
Scott Maine1e9e932011-10-13 23:36:19 -0700693receive information about a P2P group. The callback provides a {@link
694android.net.wifi.p2p.WifiP2pGroup} object, which provides group information such as the owner, the
695network name, and passphrase.</li>
696
Scott Main1d6f70c2011-10-06 22:57:25 -0700697<li>{@link android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener} interface allows you to
Scott Maine1e9e932011-10-13 23:36:19 -0700698receive information about the current connection. The callback provides a {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700699android.net.wifi.p2p.WifiP2pInfo} object, which has information such as whether a group has been
700formed and who is the group owner.</li>
701</ul>
702
703<p>In order to use the Wi-Fi P2P APIs, your app must request the following user permissions:</p>
704<ul>
705<li>{@link android.Manifest.permission#ACCESS_WIFI_STATE}</li>
706<li>{@link android.Manifest.permission#CHANGE_WIFI_STATE}</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700707<li>{@link android.Manifest.permission#INTERNET} (although your app doesn’t technically connect
708to the Internet, the WiFi Direct implementation uses sockets that do require Internet
Scott Main1d6f70c2011-10-06 22:57:25 -0700709permission to work).</li>
710</ul>
711
712<p>The Android system also broadcasts several different actions during certain Wi-Fi P2P events:</p>
713<ul>
714<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_CONNECTION_CHANGED_ACTION}: The P2P
Scott Maine1e9e932011-10-13 23:36:19 -0700715connection state has changed. This carries {@link
716android.net.wifi.p2p.WifiP2pManager#EXTRA_WIFI_P2P_INFO} with a {@link
717android.net.wifi.p2p.WifiP2pInfo} object and {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700718android.net.wifi.p2p.WifiP2pManager#EXTRA_NETWORK_INFO} with a {@link android.net.NetworkInfo}
719object.</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700720
Scott Main1d6f70c2011-10-06 22:57:25 -0700721<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_CHANGED_ACTION}: The P2P state has
Scott Maine1e9e932011-10-13 23:36:19 -0700722changed between enabled and disabled. It carries {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700723android.net.wifi.p2p.WifiP2pManager#EXTRA_WIFI_STATE} with either {@link
724android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_DISABLED} or {@link
725android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_ENABLED}</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700726
Scott Main1d6f70c2011-10-06 22:57:25 -0700727<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_PEERS_CHANGED_ACTION}: The list of peer
Scott Maine1e9e932011-10-13 23:36:19 -0700728devices has changed.</li>
729
Scott Main1d6f70c2011-10-06 22:57:25 -0700730<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_THIS_DEVICE_CHANGED_ACTION}: The details for
731this device have changed.</li>
732</ul>
733
734<p>See the {@link android.net.wifi.p2p.WifiP2pManager} documentation for more information. Also
Scott Maine1e9e932011-10-13 23:36:19 -0700735look at the <a href=”{@docRoot}resources/samples/WiFiDirectDemo/index.html”>Wi-Fi Direct Demo</a>
736sample application.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700737
738
739
740
741
742<h3 id="NetworkData">Network Data</h3>
743
Scott Maine1e9e932011-10-13 23:36:19 -0700744<p>Android 4.0 gives users precise visibility of how much network data their applications are using.
745The Settings app provides controls that allow users to manage set limits for network data usage and
746even disable the use of background data for individual apps. In order to avoid users disabling your
747app’s access to data from the background, you should develop strategies to use use the data
748connection efficiently and adjust your usage depending on the type of connection available.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700749
750<p>If your application performs a lot of network transactions, you should provide user settings that
751allow users to control your app’s data habits, such as how often your app syncs data, whether to
752perform uploads/downloads only when on Wi-Fi, whether to use data while roaming, etc. With these
753controls available to them, users are much less likely to disable your app’s access to data when
754they approach their limits, because they can instead precisely control how much data your app uses.
Scott Maine1e9e932011-10-13 23:36:19 -0700755If you provide a preference activity with these settings, you should include in its manifest
756declaration an intent filter for the {@link android.content.Intent#ACTION_MANAGE_NETWORK_USAGE}
757action. For example:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700758
759<pre>
760&lt;activity android:name="DataPreferences" android:label="@string/title_preferences">
761 &lt;intent-filter>
762 &lt;action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
763 &lt;category android:name="android.intent.category.DEFAULT" />
764 &lt;/intent-filter>
765&lt;/activity>
766</pre>
767
Scott Maine1e9e932011-10-13 23:36:19 -0700768<p>This intent filter indicates to the system that this is the activity that controls your
Scott Main1d6f70c2011-10-06 22:57:25 -0700769application’s data usage. Thus, when the user inspects how much data your app is using from the
Scott Maine1e9e932011-10-13 23:36:19 -0700770Settings app, a “View application settings” button is available that launches your
771preference activity so the user can refine how much data your app uses.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700772
773<p>Also beware that {@link android.net.ConnectivityManager#getBackgroundDataSetting()} is now
774deprecated and always returns true&mdash;use {@link
775android.net.ConnectivityManager#getActiveNetworkInfo()} instead. Before you attempt any network
776transactions, you should always call {@link android.net.ConnectivityManager#getActiveNetworkInfo()}
777to get the {@link android.net.NetworkInfo} that represents the current network and query {@link
778android.net.NetworkInfo#isConnected()} to check whether the device has a
Scott Maine1e9e932011-10-13 23:36:19 -0700779connection. You can then check other connection properties, such as whether the device is
Scott Main1d6f70c2011-10-06 22:57:25 -0700780roaming or connected to Wi-Fi.</p>
781
782
783
784
785
786
787
Scott Main1d6f70c2011-10-06 22:57:25 -0700788
Scott Maine1e9e932011-10-13 23:36:19 -0700789<h3 id="RenderScript">RenderScript</h3>
Scott Main1d6f70c2011-10-06 22:57:25 -0700790
Scott Maine1e9e932011-10-13 23:36:19 -0700791<p>Three major features have been added to RenderScript:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700792
793<ul>
794 <li>Off-screen rendering to a framebuffer object</li>
795 <li>Rendering inside a view</li>
796 <li>RS for each from the framework APIs</li>
797</ul>
798
799<p>The {@link android.renderscript.Allocation} class now supports a {@link
800android.renderscript.Allocation#USAGE_GRAPHICS_RENDER_TARGET} memory space, which allows you to
801render things directly into the {@link android.renderscript.Allocation} and use it as a framebuffer
Scott Maine1e9e932011-10-13 23:36:19 -0700802object.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700803
Scott Maine1e9e932011-10-13 23:36:19 -0700804<p>{@link android.renderscript.RSTextureView} provides a means to display RenderScript graphics
805inside of a {@link android.view.View}, unlike {@link android.renderscript.RSSurfaceView}, which
806creates a separate window. This key difference allows you to do things such as move, transform, or
807animate an {@link android.renderscript.RSTextureView} as well as draw RenderScript graphics inside
808a view that lies within an activity layout.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700809
Scott Maine1e9e932011-10-13 23:36:19 -0700810<p>The {@link android.renderscript.Script#forEach Script.forEach()} method allows you to call
811RenderScript compute scripts from the VM level and have them automatically delegated to available
812cores on the device. You do not use this method directly, but any compute RenderScript that you
813write will have a {@link android.renderscript.Script#forEach forEach()} method that you can call in
814the reflected RenderScript class. You can call the reflected {@link
815android.renderscript.Script#forEach forEach()} method by passing in an input {@link
816android.renderscript.Allocation} to process, an output {@link android.renderscript.Allocation} to
817write the result to, and a {@link android.renderscript.FieldPacker} data structure in case the
818RenderScript needs more information. Only one of the {@link android.renderscript.Allocation}s is
819necessary and the data structure is optional.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700820
821
822
823
824
825
826<h3 id="A11y">Accessibility</h3>
827
Scott Maine1e9e932011-10-13 23:36:19 -0700828<p>Android 4.0 improves accessibility for sight-impaired users with new explore-by-touch mode
829and extended APIs that allow you to provide more information about view content or
830develop advanced accessibility services.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700831
832
Scott Maine1e9e932011-10-13 23:36:19 -0700833<h4>Explore-by-touch mode</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700834
Scott Maine1e9e932011-10-13 23:36:19 -0700835<p>Users with vision loss can now explore the screen by touching and dragging a finger across the
836screen to hear voice descriptions of the content. Because the explore-by-touch mode works like a
837virtual cursor, it allows screen readers to identify the descriptive text the same way that screen
838readers can when the user navigates with a d-pad or trackball&mdash;by reading information provided
839by {@link android.R.attr#contentDescription android:contentDescription} and {@link
840android.view.View#setContentDescription setContentDescription()} upon a simulated "hover" event. So,
841consider this is a reminder that you should provide descriptive text for the views in your
842application, especially for {@link android.widget.ImageButton}, {@link android.widget.EditText},
843{@link android.widget.ImageView} and other widgets that might not naturally contain descriptive
844text.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700845
Scott Main1d6f70c2011-10-06 22:57:25 -0700846
Scott Maine1e9e932011-10-13 23:36:19 -0700847<h4>Accessibility for views</h4>
848
849<p>To enhance the information available to accessibility services such as screen readers, you can
850implement new callback methods for accessibility events in your custom {@link
851android.view.View} components.</p>
852
853<p>It's important to first note that the behavior of the {@link
854android.view.View#sendAccessibilityEvent sendAccessibilityEvent()} method has changed in Android
8554.0. As with previous version of Android, when the user enables accessibility services on the device
856and an input event such as a click or hover occurs, the respective view is notified with a call to
857{@link android.view.View#sendAccessibilityEvent sendAccessibilityEvent()}. Previously, the
858implementation of {@link android.view.View#sendAccessibilityEvent sendAccessibilityEvent()} would
859initialize an {@link android.view.accessibility.AccessibilityEvent} and send it to {@link
860android.view.accessibility.AccessibilityManager}. The new behavior involves some additional callback
861methods that allow the view and its parents to add more contextual information to the event:
Scott Main1d6f70c2011-10-06 22:57:25 -0700862<ol>
Scott Maine1e9e932011-10-13 23:36:19 -0700863 <li>When invoked, the {@link
864android.view.View#sendAccessibilityEvent sendAccessibilityEvent()} and {@link
865android.view.View#sendAccessibilityEventUnchecked sendAccessibilityEventUnchecked()} methods defer
866to {@link android.view.View#onInitializeAccessibilityEvent onInitializeAccessibilityEvent()}.
867 <p>Custom implementations of {@link android.view.View} might want to implement {@link
868android.view.View#onInitializeAccessibilityEvent onInitializeAccessibilityEvent()} to
869attach additional accessibility information to the {@link
870android.view.accessibility.AccessibilityEvent}, but should also call the super implementation to
871provide default information such as the standard content description, item index, and more.
872However, you should not add additional text content in this callback&mdash;that happens
873next.</p></li>
874 <li>Once initialized, if the event is one of several types that should be populated with text
875information, the view then receives a call to {@link
876android.view.View#dispatchPopulateAccessibilityEvent dispatchPopulateAccessibilityEvent()}, which
877defers to the {@link android.view.View#onPopulateAccessibilityEvent onPopulateAccessibilityEvent()}
878callback.
879 <p>Custom implementations of {@link android.view.View} should usually implement {@link
880android.view.View#onPopulateAccessibilityEvent onPopulateAccessibilityEvent()} to add additional
881text content to the {@link android.view.accessibility.AccessibilityEvent} if the {@link
882android.R.attr#contentDescription android:contentDescription} text is missing or
883insufficient. To add more text description to the
884{@link android.view.accessibility.AccessibilityEvent}, call {@link
885android.view.accessibility.AccessibilityEvent#getText()}.{@link java.util.List#add add()}.</p>
886</li>
887 <li>At this point, the {@link android.view.View} passes the event up the view hierarchy by calling
888{@link android.view.ViewGroup#requestSendAccessibilityEvent requestSendAccessibilityEvent()} on the
889parent view. Each parent view then has the chance to augment the accessibility information by
890adding an {@link android.view.accessibility.AccessibilityRecord}, until it
891ultimately reaches the root view, which sends the event to the {@link
892android.view.accessibility.AccessibilityManager} with {@link
893android.view.accessibility.AccessibilityManager#sendAccessibilityEvent
894sendAccessibilityEvent()}.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700895</ol>
896
Scott Maine1e9e932011-10-13 23:36:19 -0700897<p>In addition to the new methods above, which are useful when extending the {@link
898android.view.View} class, you can also intercept these event callbacks on any {@link
899android.view.View} by extending {@link
900android.view.View.AccessibilityDelegate AccessibilityDelegate} and setting it on the view with
901{@link android.view.View#setAccessibilityDelegate setAccessibilityDelegate()}.
902When you do, each accessibility method in the view defers the call to the corresponding method in
903the delegate. For example, when the view receives a call to {@link
904android.view.View#onPopulateAccessibilityEvent onPopulateAccessibilityEvent()}, it passes it to the
905same method in the {@link android.view.View.AccessibilityDelegate}. Any methods not handled by
906the delegate are given right back to the view for default behavior. This allows you to override only
907the methods necessary for any given view without extending the {@link android.view.View} class.</p>
908
909
910<p>If you want to maintain compatibility with Android versions prior to 4.0, while also supporting
911the new the accessibility APIs, you can do so with the latest version of the <em>v4 support
912library</em> (in <a href="{@docRoot}sdk/compatibility-library.html">Compatibility Package, r4</a>)
913using a set of utility classes that provide the new accessibility APIs in a backward-compatible
914design.</p>
915
916
917
918<h4>Accessibility services</h4>
919
920<p>If you're developing an accessibility service, the information about various accessibility events
921has been significantly expanded to enable more advanced accessibility feedback for users. In
922particular, events are generated based on view composition, providing better context information and
923allowing accessibility services to traverse view hierarchies to get additional view information and
924deal with special cases.</p>
925
926<p>If you're developing an accessibility service (such as a screen reader), you can access
927additional content information and traverse view hierarchies with the following procedure:</p>
928<ol>
929<li>Upon receiving an {@link android.view.accessibility.AccessibilityEvent} from an application,
930call the {@link android.view.accessibility.AccessibilityEvent#getRecord(int)
931AccessibilityEvent.getRecord()} to retrieve a specific {@link
932android.view.accessibility.AccessibilityRecord} (there may be several records attached to the
933event).</li>
934
935<li>From either {@link android.view.accessibility.AccessibilityEvent} or an individual {@link
936android.view.accessibility.AccessibilityRecord}, you can call {@link
937android.view.accessibility.AccessibilityRecord#getSource() getSource()} to retrieve a {@link
938android.view.accessibility.AccessibilityNodeInfo} object.
939 <p>An {@link android.view.accessibility.AccessibilityNodeInfo} represents a single node
940of the window content in a format that allows you to query accessibility information about that
941node. The {@link android.view.accessibility.AccessibilityNodeInfo} object returned from {@link
942android.view.accessibility.AccessibilityEvent} describes the event source, whereas the source from
943an {@link android.view.accessibility.AccessibilityRecord} describes the predecessor of the event
944source.</p></li>
945
946<li>With the {@link android.view.accessibility.AccessibilityNodeInfo}, you can query information
947about it, call {@link
948android.view.accessibility.AccessibilityNodeInfo#getParent getParent()} or {@link
949android.view.accessibility.AccessibilityNodeInfo#getChild getChild()} to traverse the view
950hierarchy, and even add child views to the node.</li>
951</ol>
952
953<p>In order for your application to publish itself to the system as an accessibility service, it
954must declare an XML configuration file that corresponds to {@link
955android.accessibilityservice.AccessibilityServiceInfo}. For more information about creating an
956accessibility service, see {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700957android.accessibilityservice.AccessibilityService} and {@link
958android.accessibilityservice.AccessibilityService#SERVICE_META_DATA
Scott Maine1e9e932011-10-13 23:36:19 -0700959SERVICE_META_DATA} for information about the XML configuration.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700960
961
Scott Maine1e9e932011-10-13 23:36:19 -0700962<h4>Other accessibility APIs</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700963
Scott Maine1e9e932011-10-13 23:36:19 -0700964<p>If you're interested in the device's accessibility state, the {@link
965android.view.accessibility.AccessibilityManager} has some new APIs such as:</p>
966<ul>
967 <li>{@link android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener}
968is an interface that allows you to receive a callback whenever accessibility is enabled or
969disabled.</li>
970 <li>{@link android.view.accessibility.AccessibilityManager#getEnabledAccessibilityServiceList
971 getEnabledAccessibilityServiceList()} provides information about which accessibility services
972 are currently enabled.</li>
973 <li>{@link android.view.accessibility.AccessibilityManager#isTouchExplorationEnabled()} tells
974 you whether the explore-by-touch mode is enabled.</li>
975</ul>
Scott Main1d6f70c2011-10-06 22:57:25 -0700976
977
978
979<h3 id="Enterprise">Enterprise</h3>
980
981<p>Android 4.0 expands the capabilities for enterprise application with the following features.</p>
982
Scott Maine1e9e932011-10-13 23:36:19 -0700983<h4>VPN services</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700984
985<p>The new {@link android.net.VpnService} allows applications to build their own VPN (Virtual
Scott Maine1e9e932011-10-13 23:36:19 -0700986Private Network), running as a {@link android.app.Service}. A VPN service creates an interface for a
987virtual network with its own address and routing rules and performs all reading and writing with a
988file descriptor.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700989
990<p>To create a VPN service, use {@link android.net.VpnService.Builder}, which allows you to specify
991the network address, DNS server, network route, and more. When complete, you can establish the
992interface by calling {@link android.net.VpnService.Builder#establish()}, which returns a {@link
993android.os.ParcelFileDescriptor}. </p>
994
995<p>Because a VPN service can intercept packets, there are security implications. As such, if you
996implement {@link android.net.VpnService}, then your service must require the {@link
997android.Manifest.permission#BIND_VPN_SERVICE} to ensure that only the system can bind to it (only
998the system is granted this permission&mdash;apps cannot request it). To then use your VPN service,
999users must manually enable it in the system settings.</p>
1000
1001
Scott Maine1e9e932011-10-13 23:36:19 -07001002<h4>Device restrictions</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001003
1004<p>Applications that manage the device restrictions can now disable the camera using {@link
1005android.app.admin.DevicePolicyManager#setCameraDisabled setCameraDisabled()} and the {@link
1006android.app.admin.DeviceAdminInfo#USES_POLICY_DISABLE_CAMERA} property (applied with a {@code
1007&lt;disable-camera /&gt;} element in the policy configuration file).</p>
1008
1009
Scott Maine1e9e932011-10-13 23:36:19 -07001010<h4>Certificate management</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001011
1012<p>The new {@link android.security.KeyChain} class provides APIs that allow you to import and access
Scott Maine1e9e932011-10-13 23:36:19 -07001013certificates in the system key store. Certificates streamline the installation of both client
1014certificates (to validate the identity of the user) and certificate authority certificates (to
1015verify server identity). Applications such as web browsers or email clients can access the installed
1016certificates to authenticate users to servers. See the {@link android.security.KeyChain}
Scott Main1d6f70c2011-10-06 22:57:25 -07001017documentation for more information.</p>
1018
1019
1020
1021
Scott Main1d6f70c2011-10-06 22:57:25 -07001022
1023
1024
Scott Maine1e9e932011-10-13 23:36:19 -07001025<h3 id="Sensors">Device Sensors</h3>
Scott Main1d6f70c2011-10-06 22:57:25 -07001026
Scott Maine1e9e932011-10-13 23:36:19 -07001027<p>Two new sensor types have been added in Android 4.0:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001028
Scott Maine1e9e932011-10-13 23:36:19 -07001029<ul>
1030 <li>{@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE}: A temperature sensor that provides
1031the ambient (room) temperature in degrees Celsius.</li>
1032 <li>{@link android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY}: A humidity sensor that provides the
1033relative ambient (room) humidity as a percentage.</li>
1034</ul>
Scott Main1d6f70c2011-10-06 22:57:25 -07001035
Scott Maine1e9e932011-10-13 23:36:19 -07001036<p>If a device has both {@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE} and {@link
1037android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY} sensors, you can use them to calculate the dew point
1038and the absolute humidity.</p>
1039
1040<p>The previous temperature sensor, {@link android.hardware.Sensor#TYPE_TEMPERATURE}, has been
1041deprecated. You should use the {@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE} sensor
1042instead.</p>
1043
1044<p>Additionally, Android’s three synthetic sensors have been improved so they now have lower latency
1045and smoother output. These sensors include the gravity sensor ({@link
1046android.hardware.Sensor#TYPE_GRAVITY}), rotation vector sensor ({@link
1047android.hardware.Sensor#TYPE_ROTATION_VECTOR}), and linear acceleration sensor ({@link
1048android.hardware.Sensor#TYPE_LINEAR_ACCELERATION}). The improved sensors rely on the gyroscope
1049sensor to improve their output, so the sensors appear only on devices that have a gyroscope.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001050
1051
1052
1053
1054
1055<h3 id="TTS">Text-to-speech Engines</h3>
1056
Scott Maine1e9e932011-10-13 23:36:19 -07001057<p>Android’s text-to-speech (TTS) APIs have been significantly extended to allow applications to
1058more easily implement custom TTS engines, while applications that want to use a TTS engine have a
1059couple new APIs for selecting an engine.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001060
1061
1062<h4>Using text-to-speech engines</h4>
1063
1064<p>In previous versions of Android, you could use the {@link android.speech.tts.TextToSpeech} class
Scott Maine1e9e932011-10-13 23:36:19 -07001065to perform text-to-speech (TTS) operations using the TTS engine provided by the system or set a
1066custom engine using {@link android.speech.tts.TextToSpeech#setEngineByPackageName
1067setEngineByPackageName()}. In Android 4.0, the {@link
1068android.speech.tts.TextToSpeech#setEngineByPackageName setEngineByPackageName()} method has been
1069deprecated and you can now specify the engine to use with a new {@link
1070android.speech.tts.TextToSpeech} constructor that accepts the package name of a TTS engine.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001071
1072<p>You can also query the available TTS engines with {@link
1073android.speech.tts.TextToSpeech#getEngines()}. This method returns a list of {@link
1074android.speech.tts.TextToSpeech.EngineInfo} objects, which include meta data such as the engine’s
1075icon, label, and package name.</p>
1076
1077
1078<h4>Building text-to-speech engines</h4>
1079
Scott Maine1e9e932011-10-13 23:36:19 -07001080<p>Previously, custom engines required that the engine be built using an undocumented native header
1081file. In Android 4.0, there is a complete set of framework APIs for building TTS engines. </p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001082
1083<p>The basic setup requires an implementation of {@link android.speech.tts.TextToSpeechService} that
1084responds to the {@link android.speech.tts.TextToSpeech.Engine#INTENT_ACTION_TTS_SERVICE} intent. The
1085primary work for a TTS engine happens during the {@link
Scott Maine1e9e932011-10-13 23:36:19 -07001086android.speech.tts.TextToSpeechService#onSynthesizeText onSynthesizeText()} callback in a service
1087that extends {@link android.speech.tts.TextToSpeechService}. The system delivers this method two
1088objects:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001089<ul>
1090<li>{@link android.speech.tts.SynthesisRequest}: This contains various data including the text to
1091synthesize, the locale, the speech rate, and voice pitch.</li>
1092<li>{@link android.speech.tts.SynthesisCallback}: This is the interface by which your TTS engine
Scott Maine1e9e932011-10-13 23:36:19 -07001093delivers the resulting speech data as streaming audio. First the engine must call {@link
Scott Main1d6f70c2011-10-06 22:57:25 -07001094android.speech.tts.SynthesisCallback#start start()} to indicate that the engine is ready to deliver
Scott Maine1e9e932011-10-13 23:36:19 -07001095the audio, then call {@link android.speech.tts.SynthesisCallback#audioAvailable audioAvailable()},
1096passing it the audio data in a byte buffer. Once your engine has passed all audio through the
1097buffer, call {@link android.speech.tts.SynthesisCallback#done()}.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -07001098</ul>
1099
Scott Maine1e9e932011-10-13 23:36:19 -07001100<p>Now that the framework supports a true API for creating TTS engines, support for the native code
1101implementation has been removed. Look for a blog post about a compatibility layer
1102that you can use to convert your old TTS engines to the new framework.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001103
1104<p>For an example TTS engine using the new APIs, see the <a
1105href=”{@docRoot}resources/samples/TtsEngine/index.html”>Text To Speech Engine</a> sample app.</p>
1106
1107
1108
1109
1110
1111
Scott Maine1e9e932011-10-13 23:36:19 -07001112<h3 id="SpellChecker">Spell Checker Services</h3>
1113
1114<p>A new spell checker framework allows apps to create spell checkers in a manner similar to the
1115input method framework. To create a new spell checker, you must implement a service that extends
1116{@link android.service.textservice.SpellCheckerService} and extend the {@link
1117android.service.textservice.SpellCheckerService.Session} class to provide spelling suggestions based
1118on text provided by interface callback methods. In the {@link
1119android.service.textservice.SpellCheckerService.Session} callback methods, you must return the
1120spelling suggestions as {@link android.view.textservice.SuggestionsInfo} objects. </p>
1121
1122<p>Applications with a spell checker service must declare the {@link
1123android.Manifest.permission#BIND_TEXT_SERVICE} permission as required by the service, such that
1124other services must have this permission in order for them to bind with the spell checker service.
1125The service must also declare an intent filter with {@code &lt;action
1126android:name="android.service.textservice.SpellCheckerService" />} as the intent’s action and should
1127include a {@code &lt;meta-data&gt;} element that declares configuration information for the spell
1128checker. </p>
1129
1130
1131
1132
Scott Main1d6f70c2011-10-06 22:57:25 -07001133
1134
1135
1136
1137
1138<h3 id="ActionBar">Action Bar</h3>
1139
1140<p>The {@link android.app.ActionBar} has been updated to support several new behaviors. Most
1141importantly, the system gracefully manages the action bar’s size and configuration when running on
Scott Maine1e9e932011-10-13 23:36:19 -07001142smaller screens in order to provide an optimal user experience on all screen sizes. For example,
1143when the screen is narrow (such as when a handset is in portrait orientation), the action bar’s
1144navigation tabs appear in a “stacked bar,” which appears directly below the main action bar. You can
1145also opt-in to a “split action bar,” which places all action items in a separate bar at the bottom
1146of the screen when the screen is narrow.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001147
1148
Scott Maine1e9e932011-10-13 23:36:19 -07001149<h4>Split action bar</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001150
Scott Maine1e9e932011-10-13 23:36:19 -07001151<p>If your action bar includes several action items, not all of them will fit into the action bar on
1152a narrow screen, so the system will place more of them into the overflow menu. However, Android 4.0
Scott Main1d6f70c2011-10-06 22:57:25 -07001153allows you to enable “split action bar” so that more action items can appear on the screen in a
1154separate bar at the bottom of the screen. To enable split action bar, add {@link
1155android.R.attr#uiOptions android:uiOptions} with {@code ”splitActionBarWhenNarrow”} to either your
Scott Maine1e9e932011-10-13 23:36:19 -07001156<a href="guide/topics/manifest/application-element.html">{@code &lt;application&gt;}</a> tag or
1157individual <a href="guide/topics/manifest/activity-element.html">{@code &lt;activity&gt;}</a> tags
1158in your manifest file. When enabled, the system will add an additional bar at the bottom of the
1159screen for all action items when the screen is narrow (no action items will appear in the primary
1160action bar).</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001161
1162<p>If you want to use the navigation tabs provided by the {@link android.app.ActionBar.Tab} APIs,
Scott Maine1e9e932011-10-13 23:36:19 -07001163but don’t need the main action bar on top (you want only the tabs to appear at the top), then enable
1164the split action bar as described above and also call {@link
1165android.app.ActionBar#setDisplayShowHomeEnabled setDisplayShowHomeEnabled(false)} to disable the
1166application icon in the action bar. With nothing left in the main action bar, it
1167disappears&mdash;all that’s left are the navigation tabs at the top and the action items at the
1168bottom of the screen.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001169
1170
Scott Maine1e9e932011-10-13 23:36:19 -07001171<h4>Action bar styles</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001172
1173<p>If you want to apply custom styling to the action bar, you can use new style properties {@link
1174android.R.attr#backgroundStacked} and {@link android.R.attr#backgroundSplit} to apply a background
1175drawable or color to the stacked bar and split bar, respectively. You can also set these styles at
1176runtime with {@link android.app.ActionBar#setStackedBackgroundDrawable
1177setStackedBackgroundDrawable()} and {@link android.app.ActionBar#setSplitBackgroundDrawable
1178setSplitBackgroundDrawable()}.</p>
1179
1180
Scott Maine1e9e932011-10-13 23:36:19 -07001181<h4>Action provider</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001182
Scott Maine1e9e932011-10-13 23:36:19 -07001183<p>The new {@link android.view.ActionProvider} class allows you to create a specialized handler for
1184action items. An action provider can define an action view, a default action behavior, and a submenu
1185for each action item to which it is associated. When you want to create an action item that has
1186dynamic behaviors (such as a variable action view, default action, or submenu), extending {@link
1187android.view.ActionProvider} is a good solution in order to create a reusable component, rather than
1188handling the various action item transformations in your fragment or activity.</p>
1189
1190<p>For example, the {@link android.widget.ShareActionProvider} is an extension of {@link
1191android.view.ActionProvider} that facilitates a “share” action from the action bar. Instead of using
1192traditional action item that invokes the {@link android.content.Intent#ACTION_SEND} intent, you can
1193use this action provider to present an action view with a drop-down list of applications that handle
1194the {@link android.content.Intent#ACTION_SEND} intent. When the user selects an application to use
1195for the action, {@link android.widget.ShareActionProvider} remembers that selection and provides it
1196in the action view for faster access to sharing with that app.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001197
1198<p>To declare an action provider for an action item, include the {@code android:actionProviderClass}
Scott Maine1e9e932011-10-13 23:36:19 -07001199attribute in the <a href="{@docRoot}guide/topics/resources/menu-resource.html#item-element">{@code
1200&lt;item&gt;}</a> element for your activity’s options menu, with the class name of the action
1201provider as the value. For example:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001202
1203<pre>
1204&lt;item android:id="@+id/menu_share"
1205 android:title="Share"
Scott Main1d6f70c2011-10-06 22:57:25 -07001206 android:showAsAction="ifRoom"
1207 android:actionProviderClass="android.widget.ShareActionProvider" /&gt;
1208</pre>
1209
1210<p>In your activity’s {@link android.app.Activity#onCreateOptionsMenu onCreateOptionsMenu()}
Scott Maine1e9e932011-10-13 23:36:19 -07001211callback method, retrieve an instance of the action provider from the menu item and set the
1212intent:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001213
1214<pre>
1215public boolean onCreateOptionsMenu(Menu menu) {
1216 getMenuInflater().inflate(R.menu.options, menu);
1217 ShareActionProvider shareActionProvider =
1218 (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider();
1219 // Set the share intent of the share action provider.
1220 shareActionProvider.setShareIntent(createShareIntent());
1221 ...
1222 return super.onCreateOptionsMenu(menu);
1223}
1224</pre>
1225
1226<p>For an example using the {@link android.widget.ShareActionProvider}, see the <a
1227href=”{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/ActionBarActionProviderActivity.html”>ActionBarActionProviderActivity</a>
1228class in ApiDemos.</p>
1229
1230
Scott Maine1e9e932011-10-13 23:36:19 -07001231<h4>Collapsible action views</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001232
Scott Maine1e9e932011-10-13 23:36:19 -07001233<p>Action items that provide an action view can now toggle between their action view state and
Scott Main1d6f70c2011-10-06 22:57:25 -07001234traditional action item state. Previously only the {@link android.widget.SearchView} supported
1235collapsing when used as an action view, but now you can add an action view for any action item and
1236switch between the expanded state (action view is visible) and collapsed state (action item is
1237visible).</p>
1238
1239<p>To declare that an action item that contains an action view be collapsible, include the {@code
Scott Maine1e9e932011-10-13 23:36:19 -07001240“collapseActionView”} flag in the {@code android:showAsAction} attribute for the <a
1241href="{@docRoot}guide/topics/resources/menu-resource.html#item-element">{@code
1242&lt;item&gt;}</a> element in the menu’s XML file.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001243
1244<p>To receive callbacks when an action view switches between expanded and collapsed, register an
1245instance of {@link android.view.MenuItem.OnActionExpandListener} with the respective {@link
1246android.view.MenuItem} by calling {@link android.view.MenuItem#setOnActionExpandListener
1247setOnActionExpandListener()}. Typically, you should do so during the {@link
1248android.app.Activity#onCreateOptionsMenu onCreateOptionsMenu()} callback.</p>
1249
1250<p>To control a collapsible action view, you can call {@link
1251android.view.MenuItem#collapseActionView()} and {@link android.view.MenuItem#expandActionView()} on
1252the respective {@link android.view.MenuItem}.</p>
1253
1254<p>When creating a custom action view, you can also implement the new {@link
1255android.view.CollapsibleActionView} interface to receive callbacks when the view is expanded and
1256collapsed.</p>
1257
1258
Scott Maine1e9e932011-10-13 23:36:19 -07001259<h4>Other APIs for action bar</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001260<ul>
Scott Maine1e9e932011-10-13 23:36:19 -07001261<li>{@link android.app.ActionBar#setHomeButtonEnabled setHomeButtonEnabled()} allows you to specify
1262whether the icon/logo behaves as a button to navigate home or “up” (pass “true” to make it behave as
1263a button).</li>
1264
Scott Main1d6f70c2011-10-06 22:57:25 -07001265<li>{@link android.app.ActionBar#setIcon setIcon()} and {@link android.app.ActionBar#setLogo
Scott Maine1e9e932011-10-13 23:36:19 -07001266setLogo()} allow you to define the action bar icon or logo at runtime.</li>
1267
Scott Main1d6f70c2011-10-06 22:57:25 -07001268<li>{@link android.app.Fragment#setMenuVisibility Fragment.setMenuVisibility()} allows you to enable
Scott Maine1e9e932011-10-13 23:36:19 -07001269or disable the visibility of the options menu items declared by the fragment. This is useful if the
Scott Main1d6f70c2011-10-06 22:57:25 -07001270fragment has been added to the activity, but is not visible, so the menu items should be
1271hidden.</li>
Scott Maine1e9e932011-10-13 23:36:19 -07001272
Scott Main1d6f70c2011-10-06 22:57:25 -07001273<li>{@link android.app.FragmentManager#invalidateOptionsMenu
1274FragmentManager.invalidateOptionsMenu()}
1275allows you to invalidate the activity options menu during various states of the fragment lifecycle
1276in which using the equivalent method from {@link android.app.Activity} might not be available.</li>
1277</ul>
1278
1279
1280
1281
1282
1283
1284
1285
1286<h3 id="UI">User Interface and Views</h3>
1287
1288<p>Android 4.0 introduces a variety of new views and other UI components.</p>
1289
Scott Maine1e9e932011-10-13 23:36:19 -07001290
Scott Main1d6f70c2011-10-06 22:57:25 -07001291<h4>System UI</h4>
1292
1293<p>Since the early days of Android, the system has managed a UI component known as the <em>status
1294bar</em>, which resides at the top of handset devices to deliver information such as the carrier
1295signal, time, notifications, and so on. Android 3.0 added the <em>system bar</em> for tablet
1296devices, which resides at the bottom of the screen to provide system navigation controls (Home,
1297Back, and so forth) and also an interface for elements traditionally provided by the status bar. In
1298Android 4.0, the system provides a new type of system UI called the <em>navigation bar</em>. The
1299navigation bar shares some qualities with the system bar, because it provides navigation controls
1300for devices that don’t have hardware counterparts for navigating the system, but the navigation
Scott Maine1e9e932011-10-13 23:36:19 -07001301controls is all that the navigation bar offers (a device with the navigation bar, thus, also
1302includes the status bar at the top of the screen).</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001303
1304<p>To this day, you can hide the status bar on handsets using the {@link
1305android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN} flag. In Android 4.0, the APIs that control
1306the system bar’s visibility have been updated to better reflect the behavior of both the system bar
1307and navigation bar:</p>
1308<ul>
1309<li>The {@link android.view.View#SYSTEM_UI_FLAG_LOW_PROFILE} flag replaces View.STATUS_BAR_HIDDEN
Scott Maine1e9e932011-10-13 23:36:19 -07001310flag. When set, this flag enables “low profile” mode for the system bar or
1311navigation bar. Navigation buttons dim and other elements in the system bar also hide.</li>
1312
Scott Main1d6f70c2011-10-06 22:57:25 -07001313<li>The {@link android.view.View#SYSTEM_UI_FLAG_VISIBLE} flag replaces the {@code
Scott Maine1e9e932011-10-13 23:36:19 -07001314STATUS_BAR_VISIBLE} flag to request the system bar or navigation bar be visible.</li>
1315
Scott Main1d6f70c2011-10-06 22:57:25 -07001316<li>The {@link android.view.View#SYSTEM_UI_FLAG_HIDE_NAVIGATION} is a new flag that requests that
Scott Maine1e9e932011-10-13 23:36:19 -07001317the navigation bar hide completely. Take note that this works only for the <em>navigation bar</em>
1318used by some handsets (it does <strong>not</strong> hide the system bar on tablets). The navigation
1319bar returns as soon as the system receives user input. As such, this mode is generally used for
1320video playback or other cases in which the whole screen is needed but user input is not
1321required.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -07001322</ul>
1323
Scott Maine1e9e932011-10-13 23:36:19 -07001324<p>You can set each of these flags for the system bar and navigation bar by calling {@link
1325android.view.View#setSystemUiVisibility setSystemUiVisibility()} on any view in your activity. The
1326window manager will combine (OR-together) all flags from all views in your window and
Scott Main1d6f70c2011-10-06 22:57:25 -07001327apply them to the system UI as long as your window has input focus. When your window loses input
1328focus (the user navigates away from your app, or a dialog appears), your flags cease to have effect.
1329Similarly, if you remove those views from the view hierarchy their flags no longer apply.</p>
1330
1331<p>To synchronize other events in your activity with visibility changes to the system UI (for
Scott Maine1e9e932011-10-13 23:36:19 -07001332example, hide the action bar or other UI controls when the system UI hides), you should register a
1333{@link android.view.View.OnSystemUiVisibilityChangeListener} to be notified when the visibility
1334of the system bar or navigation bar changes.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001335
1336<p>See the <a
1337href=”{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/OverscanActivity.html”>
1338OverscanActivity</a> class for a demonstration of different system UI options.</p>
1339
1340
1341<h4>GridLayout</h4>
1342
1343<p>{@link android.widget.GridLayout} is a new view group that places child views in a rectangular
Scott Maine1e9e932011-10-13 23:36:19 -07001344grid. Unlike {@link android.widget.TableLayout}, {@link android.widget.GridLayout} relies on a flat
Scott Main1d6f70c2011-10-06 22:57:25 -07001345hierarchy and does not make use of intermediate views such as table rows for providing structure.
1346Instead, children specify which row(s) and column(s) they should occupy (cells can span multiple
1347rows and/or columns), and by default are laid out sequentially across the grid’s rows and columns.
1348The {@link android.widget.GridLayout} orientation determines whether sequential children are by
1349default laid out horizontally or vertically. Space between children may be specified either by using
1350instances of the new {@link android.widget.Space} view or by setting the relevant margin parameters
1351on children.</p>
1352
1353<p>See <a
1354href=”{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/index.html”>ApiDemos</a>
1355for samples using {@link android.widget.GridLayout}.</p>
1356
1357
1358
1359<h4>TextureView</h4>
1360
1361<p>{@link android.view.TextureView} is a new view that allows you to display a content stream, such
Scott Maine1e9e932011-10-13 23:36:19 -07001362as a video or an OpenGL scene. Although similar to {@link android.view.SurfaceView}, {@link
Scott Main1d6f70c2011-10-06 22:57:25 -07001363android.view.TextureView} is unique in that it behaves like a regular view, rather than creating a
1364separate window, so you can treat it like any other {@link android.view.View} object. For example,
Scott Maine1e9e932011-10-13 23:36:19 -07001365you can apply transforms, animate it using {@link android.view.ViewPropertyAnimator}, or
Scott Main1d6f70c2011-10-06 22:57:25 -07001366adjust its opacity with {@link android.view.View#setAlpha setAlpha()}.</p>
1367
1368<p>Beware that {@link android.view.TextureView} works only within a hardware accelerated window.</p>
1369
1370<p>For more information, see the {@link android.view.TextureView} documentation.</p>
1371
1372
Scott Maine1e9e932011-10-13 23:36:19 -07001373<h4>Switch widget</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001374
1375<p>The new {@link android.widget.Switch} widget is a two-state toggle that users can drag to one
Scott Maine1e9e932011-10-13 23:36:19 -07001376side or the other (or simply tap) to toggle an option between two states.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001377
Scott Maine1e9e932011-10-13 23:36:19 -07001378<p>You can use the {@code android:textOn} and {@code android:textOff} attributes to specify the text
1379to appear on the switch when in the on and off setting. The {@code android:text} attribute also
1380allows you to place a label alongside the switch.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001381
1382<p>For a sample using switches, see the <a
1383href=”{@docRoot}resources/samples/ApiDemos/res/layout/switches.html”>switches.xml</a> layout file
1384and respective <a
1385href=”{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/Switches.html”>Switches
1386</a> activity.</p>
1387
1388
Scott Maine1e9e932011-10-13 23:36:19 -07001389<h4>Popup menus</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001390
1391<p>Android 3.0 introduced {@link android.widget.PopupMenu} to create short contextual menus that pop
Scott Maine1e9e932011-10-13 23:36:19 -07001392up at an anchor point you specify (usually at the point of the item selected). Android 4.0 extends
1393the {@link android.widget.PopupMenu} with a couple useful features:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001394<ul>
1395<li>You can now easily inflate the contents of a popup menu from an XML <a
1396href=”{@docRoot}guide/topics/resources/menu-resource.html”>menu resource</a> with {@link
1397android.widget.PopupMenu#inflate inflate()}, passing it the menu resource ID.</li>
1398<li>You can also now create a {@link android.widget.PopupMenu.OnDismissListener} that receives a
1399callback when the menu is dismissed.</li>
1400</ul>
1401
Scott Maine1e9e932011-10-13 23:36:19 -07001402
Scott Main1d6f70c2011-10-06 22:57:25 -07001403<h4>Preferences</h4>
1404
1405<p>A new {@link android.preference.TwoStatePreference} abstract class serves as the basis for
1406preferences that provide a two-state selection option. The new {@link
1407android.preference.SwitchPreference} is an extension of {@link
1408android.preference.TwoStatePreference} that provides a {@link android.widget.Switch} widget in the
1409preference view to allow users to toggle a setting on or off without the need to open an additional
1410preference screen or dialog. For example, the Settings application uses a {@link
1411android.preference.SwitchPreference} for the Wi-Fi and Bluetooth settings.</p>
1412
1413
Scott Maine1e9e932011-10-13 23:36:19 -07001414<h4>Hover events</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001415
1416<p>The {@link android.view.View} class now supports “hover” events to enable richer interactions
Scott Maine1e9e932011-10-13 23:36:19 -07001417through the use of pointer devices (such as a mouse or other devices that drive an on-screen
Scott Main1d6f70c2011-10-06 22:57:25 -07001418cursor).</p>
1419
1420<p>To receive hover events on a view, implement the {@link android.view.View.OnHoverListener} and
1421register it with {@link android.view.View#setOnHoverListener setOnHoverListener()}. When a hover
1422event occurs on the view, your listener receives a call to {@link
1423android.view.View.OnHoverListener#onHover onHover()}, providing the {@link android.view.View} that
1424received the event and a {@link android.view.MotionEvent} that describes the type of hover event
1425that occurred. The hover event can be one of the following:</p>
1426<ul>
1427<li>{@link android.view.MotionEvent#ACTION_HOVER_ENTER}</li>
1428<li>{@link android.view.MotionEvent#ACTION_HOVER_EXIT}</li>
1429<li>{@link android.view.MotionEvent#ACTION_HOVER_MOVE}</li>
1430</ul>
1431
1432<p>Your {@link android.view.View.OnHoverListener} should return true from {@link
1433android.view.View.OnHoverListener#onHover onHover()} if it handles the hover event. If your
1434listener returns false, then the hover event will be dispatched to the parent view as usual.</p>
1435
1436<p>If your application uses buttons or other widgets that change their appearance based on the
Scott Maine1e9e932011-10-13 23:36:19 -07001437current state, you can now use the {@code android:state_hovered} attribute in a <a
Scott Main1d6f70c2011-10-06 22:57:25 -07001438href=”{@docRoot}guide/topics/resources/drawable-resource.html#StateList”>state list drawable</a> to
1439provide a different background drawable when a cursor hovers over the view.</p>
1440
1441<p>For a demonstration of the new hover events, see the <a
1442href=”{@docRoot}samples/ApiDemos/src/com/example/android/apis/view/Hover.html”>Hover</a> class in
1443ApiDemos.</p>
1444
1445
Scott Maine1e9e932011-10-13 23:36:19 -07001446<h4>Stylus and mouse button events</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001447
1448<p>Android now provides APIs for receiving input from a stylus input device such as a digitizer
Scott Maine1e9e932011-10-13 23:36:19 -07001449tablet peripheral or a stylus-enabled touch screen.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001450
1451<p>Stylus input operates in a similar manner to touch or mouse input. When the stylus is in contact
1452with the digitizer, applications receive touch events just like they would when a finger is used to
1453touch the display. When the stylus is hovering above the digitizer, applications receive hover
1454events just like they would when a mouse pointer was being moved across the display when no buttons
1455are pressed.</p>
1456
1457<p>Your application can distinguish between finger, mouse, stylus and eraser input by querying the
1458“tool type” associated with each pointer in a {@link android.view.MotionEvent} using {@link
1459android.view.MotionEvent#getToolType getToolType()}. The currently defined tool types are: {@link
1460android.view.MotionEvent#TOOL_TYPE_UNKNOWN}, {@link android.view.MotionEvent#TOOL_TYPE_FINGER},
1461{@link android.view.MotionEvent#TOOL_TYPE_MOUSE}, {@link android.view.MotionEvent#TOOL_TYPE_STYLUS},
1462and {@link android.view.MotionEvent#TOOL_TYPE_ERASER}. By querying the tool type, your application
1463can choose to handle stylus input in different ways from finger or mouse input.</p>
1464
1465<p>Your application can also query which mouse or stylus buttons are pressed by querying the “button
1466state” of a {@link android.view.MotionEvent} using {@link android.view.MotionEvent#getButtonState
1467getButtonState()}. The currently defined button states are: {@link
Scott Maine1e9e932011-10-13 23:36:19 -07001468android.view.MotionEvent#BUTTON_PRIMARY}, {@link android.view.MotionEvent#BUTTON_SECONDARY}, {@link
1469android.view.MotionEvent#BUTTON_TERTIARY}, {@link android.view.MotionEvent#BUTTON_BACK}, and {@link
1470android.view.MotionEvent#BUTTON_FORWARD}. For convenience, the back and forward mouse buttons are
1471automatically mapped to the {@link android.view.KeyEvent#KEYCODE_BACK} and {@link
1472android.view.KeyEvent#KEYCODE_FORWARD} keys. Your application can handle these keys to support
1473mouse button based back and forward navigation.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001474
1475<p>In addition to precisely measuring the position and pressure of a contact, some stylus input
Scott Maine1e9e932011-10-13 23:36:19 -07001476devices also report the distance between the stylus tip and the digitizer, the stylus tilt angle,
1477and the stylus orientation angle. Your application can query this information using {@link
Scott Main1d6f70c2011-10-06 22:57:25 -07001478android.view.MotionEvent#getAxisValue getAxisValue()} with the axis codes {@link
1479android.view.MotionEvent#AXIS_DISTANCE}, {@link android.view.MotionEvent#AXIS_TILT}, and {@link
1480android.view.MotionEvent#AXIS_ORIENTATION}.</p>
1481
1482<p>For a demonstration of tool types, button states and the new axis codes, see the <a
1483href=”{@docRoot}samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html”>TouchPaint
1484</a> class in ApiDemos.</p>
1485
1486
1487
1488
1489
1490
1491<h3 id="Properties">Properties</h3>
1492
1493<p>The new {@link android.util.Property} class provides a fast, efficient, and easy way to specify a
1494property on any object that allows callers to generically set/get values on target objects. It also
1495allows the functionality of passing around field/method references and allows code to set/get values
1496of the property without knowing the details of what the fields/methods are.</p>
1497
1498<p>For example, if you want to set the value of field {@code bar} on object {@code foo}, you would
1499previously do this:</p>
1500<pre>
1501foo.bar = value;
1502</pre>
1503
1504<p>If you want to call the setter for an underlying private field {@code bar}, you would previously
1505do this:</p>
1506<pre>
1507foo.setBar(value);
1508</pre>
1509
1510<p>However, if you want to pass around the {@code foo} instance and have some other code set the
1511{@code bar} value, there is really no way to do it prior to Android 4.0.</p>
1512
1513<p>Using the {@link android.util.Property} class, you can declare a {@link android.util.Property}
1514object {@code BAR} on class {@code Foo} so that you can set the field on instance {@code foo} of
1515class {@code Foo} like this:</p>
1516<pre>
1517BAR.set(foo, value);
1518</pre>
1519
1520<p>The {@link android.view.View} class now leverages the {@link android.util.Property} class to
1521allow you to set various fields, such as transform properties that were added in Android 3.0 ({@link
1522android.view.View#ROTATION}, {@link android.view.View#ROTATION_X}, {@link
1523android.view.View#TRANSLATION_X}, etc.).</p>
1524
1525<p>The {@link android.animation.ObjectAnimator} class also uses the {@link android.util.Property}
1526class, so you can create an {@link android.animation.ObjectAnimator} with a {@link
1527android.util.Property}, which is faster, more efficient, and more type-safe than the string-based
1528approach.</p>
1529
1530
1531
1532
1533
1534
1535<h3 id="HwAccel">Hardware Acceleration</h3>
1536
1537<p>Beginning with Android 4.0, hardware acceleration for all windows is enabled by default if your
1538application has set either <a
1539href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> or
1540<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> to
1541{@code “14”} or higher. Hardware acceleration generally results in smoother animations, smoother
1542scrolling, and overall better performance and response to user interaction.</p>
1543
1544<p>If necessary, you can manually disable hardware acceleration with the <a
1545href=”{@docRoot}guide/topics/manifest/activity-element.html#hwaccel”>{@code hardwareAccelerated}</a>
1546attribute for individual <a href="{@docRoot}guide/topics/manifest/activity-element.html">{@code
1547&lt;activity&gt;}</a> elements or the <a
1548href="{@docRoot}guide/topics/manifest/application-element.html">{@code &lt;application&gt;}</a>
1549element. You can alternatively disable hardware acceleration for individual views by calling {@link
1550android.view.View#setLayerType setLayerType(LAYER_TYPE_SOFTWARE)}.</p>
1551
Scott Maine1e9e932011-10-13 23:36:19 -07001552<p>For more information about hardware acceleration, including a list of unsupported drawing
1553operations, see the <a href="{@docRoot}guide/topics/graphics/hardware-accel.html">Hardware
1554Acceleration</a> document.</p>
1555
1556
Scott Main1d6f70c2011-10-06 22:57:25 -07001557
1558<h3 id="Jni">JNI Changes</h3>
1559
Scott Maine1e9e932011-10-13 23:36:19 -07001560<p>In previous versions of Android, JNI local references weren’t indirect handles; Android used
1561direct pointers. This wasn't a problem as long as the garbage collector didn't move objects, but it
1562seemed to work because it made it possible to write buggy code. In Android 4.0, the system now uses
1563indirect references in order to detect these bugs.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001564
Scott Maine1e9e932011-10-13 23:36:19 -07001565<p>The ins and outs of JNI local references are described in “Local and Global References” in <a
1566href="{@docRoot}guide/practices/design/jni.html">JNI Tips</a>. In Android 4.0, <a
1567href="http://android-developers.blogspot.com/2011/07/debugging-android-jni-with-checkjni.html">
1568CheckJNI</a> has been enhanced to detect these errors. Watch the <a
1569href=”http://android-developers.blogspot.com/”>Android Developers Blog</a> for an upcoming post
1570about common errors with JNI references and how you can fix them.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001571
1572<p>This change in the JNI implementation only affects apps that target Android 4.0 by setting either
Scott Maine1e9e932011-10-13 23:36:19 -07001573the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
1574targetSdkVersion}</a> or <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
1575minSdkVersion}</a> to {@code “14”} or higher. If you’ve set these attributes to any lower value,
1576then JNI local references behave the same as in previous versions.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001577
1578
1579
1580
1581
1582<h3 id="WebKit">WebKit</h3>
1583<ul>
1584<li>WebKit updated to version 534.30</li>
1585<li>Support for Indic fonts (Devanagari, Bengali, and Tamil, including the complex character support
1586needed for combining glyphs) in {@link android.webkit.WebView} and the built-in Browser</li>
1587<li>Support for Ethiopic, Georgian, and Armenian fonts in {@link android.webkit.WebView} and the
1588built-in Browser</li>
1589<li>Support for <a
1590href="http://google-opensource.blogspot.com/2009/05/introducing-webdriver.html">WebDriver</a> makes
1591it easier for you to test apps that use {@link android.webkit.WebView}</li>
1592</ul>
1593
1594
1595<h4>Android Browser</h4>
1596
1597<p>The Browser application adds the following features to support web applications:</p>
1598<ul>
1599<li>Updated V8 JavaScript compiler for faster performance</li>
1600<li>Plus other notable enhancements carried over from <a
1601href=”{@docRoot}sdk/android-3.0.html”>Android
16023.0</a> are now available for handsets:
1603<ul>
1604<li>Support for fixed position elements on all pages</li>
1605<li><a href="http://dev.w3.org/2009/dap/camera/">HTML media capture</a></li>
1606<li><a href="http://dev.w3.org/geo/api/spec-source-orientation.html">Device orientation
1607events</a></li>
1608<li><a href="http://www.w3.org/TR/css3-3d-transforms/">CSS 3D transformations</a></li>
1609</ul>
1610</li>
1611</ul>
1612
1613
1614
1615<h3 id="Permissions">Permissions</h3>
1616
1617<p>The following are new permissions:</p>
1618<ul>
1619<li>{@link android.Manifest.permission#ADD_VOICEMAIL}: Allows a voicemail service to add voicemail
1620messages to the device.</li>
1621<li>{@link android.Manifest.permission#BIND_TEXT_SERVICE}: A service that implements {@link
1622android.service.textservice.SpellCheckerService} must require this permission for itself.</li>
1623<li>{@link android.Manifest.permission#BIND_VPN_SERVICE}: A service that implements {@link
1624android.net.VpnService} must require this permission for itself.</li>
1625<li>{@link android.Manifest.permission#READ_PROFILE}: Provides read access to the {@link
1626android.provider.ContactsContract.Profile} provider.</li>
1627<li>{@link android.Manifest.permission#WRITE_PROFILE}: Provides write access to the {@link
1628android.provider.ContactsContract.Profile} provider.</li>
1629</ul>
1630
1631
1632
1633<h3 id="DeviceFeatures">Device Features</h3>
1634
1635<p>The following are new device features:</p>
1636<ul>
1637<li>{@link android.content.pm.PackageManager#FEATURE_WIFI_DIRECT}: Declares that the application
1638uses
1639Wi-Fi for peer-to-peer communications.</li>
1640</ul>
1641
1642
1643
Scott Maine1e9e932011-10-13 23:36:19 -07001644<h2 id="Honeycomb">Previous APIs</h2>
Scott Main1d6f70c2011-10-06 22:57:25 -07001645
Scott Maine1e9e932011-10-13 23:36:19 -07001646<p>In addition to everything above, Android 4.0 naturally supports all APIs from previous releases.
1647Because the Android 3.x (Honeycomb) platform is available only for large-screen devices, if you've
1648been developing primarily for handsets, then you might not be aware of all the APIs added to Android
1649in these recent releases.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001650
Scott Maine1e9e932011-10-13 23:36:19 -07001651<p>Here's a look at some of the most notable APIs you might have missed that are now available
1652on handsets as well:</p>
1653
1654<dl>
1655 <dt><a href="android-3.0.html">Android 3.0</a></dt>
1656 <dd>
1657 <ul>
1658 <li>{@link android.app.Fragment}: A framework component that allows you to separate distinct
1659elements of an activity into self-contained modules that define their own UI and lifecycle. See the
1660<a href="{@docRoot}guide/topics/fundamentals/fragments.html">Fragments</a> developer guide.</li>
1661 <li>{@link android.app.ActionBar}: A replacement for the traditional title bar at the top of
1662the activity window. It includes the application logo in the left corner and provides a new
1663interface for menu items. See the
1664<a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer guide.</li>
1665 <li>{@link android.content.Loader}: A framework component that facilitates asynchronour
1666loading of data in combination with UI components to dynamically load data without blocking the
1667main thread. See the
1668<a href="{@docRoot}guide/topics/fundamentals/loaders.html">Loaders</a> developer guide.</li>
1669 <li>System clipboard: Applications can copy and paste data (beyond mere text) to and from
1670the system-wide clipboard. Clipped data can be plain text, a URI, or an intent. See the
1671<a href="{@docRoot}guide/topics/clipboard/copy-paste.html">Copy and Paste</a> developer guide.</li>
1672 <li>Drag and drop: A set of APIs built into the view framework that facilitates drag and drop
1673operations. See the
1674<a href="{@docRoot}guide/topics/ui/drag-drop.html">Drag and Drop</a> developer guide.</li>
1675 <li>An all new flexible animation framework allows you to animate arbitrary properties of any
1676object (View, Drawable, Fragment, Object, or anything else) and define animation aspects such
1677as duration, interpolation, repeat and more. The new framework makes Animations in Android
1678simpler than ever. See the
1679<a href="{@docRoot}guide/topics/graphics/property-animation.html">Property Animation</a> developer
1680guide.</li>
1681 <li>RenderScript graphics and compute engine: RenderScript offers a high performance 3D
1682graphics rendering and compute API at the native level, which you write in the C (C99 standard),
1683providing the type of performance you expect from a native environment while remaining portable
1684across various CPUs and GPUs. See the
1685<a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer
1686guide.</li>
1687 <li>Hardware accelerated 2D graphics: You can now enable the OpenGL renderer for your
1688application by setting {android:hardwareAccelerated="true"} in your manifest element's <a
1689href="{@docRoot}guide/topics/manifest/application-element.html"><code>&lt;application&gt;</code></a>
1690element or for individual <a
1691href="{@docRoot}guide/topics/manifest/activity-element.html"><code>&lt;activity&gt;</code></a>
1692elements. This results
1693in smoother animations, smoother scrolling, and overall better performance and response to user
1694interaction.
1695 <p class="note"><strong>Note:</strong> If you set your application's <a
1696href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> or <a
1697href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> to
1698{@code "14"} or higher, hardware acceleration is enabled by default.</p></li>
1699 <li>And much, much more. See the <a href="android-3.0.html">Android 3.0 Platform</a>
1700notes for more information.</li>
1701 </ul>
1702 </dd>
1703
1704 <dt><a href="android-3.1.html">Android 3.1</a></dt>
1705 <dd>
1706 <ul>
1707 <li>USB APIs: Powerful new APIs for integrating connected peripherals with
1708Android applications. The APIs are based on a USB stack and services that are
1709built into the platform, including support for both USB host and device interactions. See the <a
1710href="{@docRoot}guide/topics/usb/index.html">USB Host and Accessory</a> developer guide.</li>
1711 <li>MTP/PTP APIs: Applications can interact directly with connected cameras and other PTP
1712devices to receive notifications when devices are attached and removed, manage files and storage on
1713those devices, and transfer files and metadata to and from them. The MTP API implements the PTP
1714(Picture Transfer Protocol) subset of the MTP (Media Transfer Protocol) specification. See the
1715{@link android.mtp} documentation.</li>
1716 <li>RTP APIs: Android exposes an API to its built-in RTP (Real-time Transport Protocol) stack,
1717which applications can use to manage on-demand or interactive data streaming. In particular, apps
1718that provide VOIP, push-to-talk, conferencing, and audio streaming can use the API to initiate
1719sessions and transmit or receive data streams over any available network. See the {@link
1720android.net.rtp} documentation.</li>
1721 <li>Support for joysticks and other generic motion inputs.</li>
1722 <li>See the <a href="android-3.1.html">Android 3.1 Platform</a>
1723notes for many more new APIs.</li>
1724 </ul>
1725 </dd>
1726
1727 <dt><a href="android-3.2.html">Android 3.2</a></dt>
1728 <dd>
1729 <ul>
1730 <li>New screens support APIs that give you more control over how your applications are
1731displayed across different screen sizes. The API extends the existing screen support model with the
1732ability to precisely target specific screen size ranges by dimensions, measured in
1733density-independent pixel units (such as 600dp or 720dp wide), rather than by their generalized
1734screen sizes (such as large or xlarge). For example, this is important in order to help you
1735distinguish between a 5" device and a 7" device, which would both traditionally be bucketed as
1736"large" screens. See the blog post, <a
1737href="http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html">
1738New Tools for Managing Screen Sizes</a>.</li>
1739 <li>New constants for <a
1740href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a> to
1741declare landscape or portrait screen orientation requirements.</li>
1742 <li>The device "screen size" configuration now changes during a screen orientation
1743change. If your app targets API level 13 or higher, you must handle the {@code "screenSize"}
1744configuration change if you also want to handle the {@code "orientation"} configuration change. See
1745<a href="{@docRoot}guide/topics/manifest/activity-element.html#config">{@code
1746android:configChanges}</a> for more information.</li>
1747 <li>See the <a href="android-3.2.html">Android 3.2 Platform</a>
1748notes for other new APIs.</li>
1749 </ul>
1750 </dd>
1751
1752</dl>
Scott Main1d6f70c2011-10-06 22:57:25 -07001753
1754
1755
1756
1757
1758
1759<h2 id="api-diff">API Differences Report</h2>
1760
Scott Maine1e9e932011-10-13 23:36:19 -07001761<p>For a detailed view of all API changes in Android {@sdkPlatformVersion} (API Level
Scott Main1d6f70c2011-10-06 22:57:25 -07001762{@sdkPlatformApiLevel}), see the <a
Scott Maine1e9e932011-10-13 23:36:19 -07001763href="{@docRoot}sdk/api_diff/{@sdkPlatformApiLevel}/changes.html">API Differences Report</a>.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001764
1765
1766
1767<h2 id="api-level">API Level</h2>
1768
Scott Maine1e9e932011-10-13 23:36:19 -07001769<p>The Android {@sdkPlatformVersion} API is assigned an integer
1770identifier&mdash;<strong>{@sdkPlatformApiLevel}</strong>&mdash;that is stored in the system itself.
1771This identifier, called the "API level", allows the system to correctly determine whether an
1772application is compatible with the system, prior to installing the application. </p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001773
1774<p>To use APIs introduced in Android {@sdkPlatformVersion} in your application, you need compile the
Scott Maine1e9e932011-10-13 23:36:19 -07001775application against an Android platform that supports API level {@sdkPlatformApiLevel} or
1776higher. Depending on your needs, you might also need to add an
Scott Main1d6f70c2011-10-06 22:57:25 -07001777<code>android:minSdkVersion="{@sdkPlatformApiLevel}"</code> attribute to the
Scott Maine1e9e932011-10-13 23:36:19 -07001778<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code &lt;uses-sdk&gt;}</a>
1779element.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001780
Scott Maine1e9e932011-10-13 23:36:19 -07001781<p>For more information, see the <a href="{@docRoot}guide/appendix/api-levels.html">API Levels</a>
1782document. </p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001783
1784
1785<h2 id="apps">Built-in Applications</h2>
1786
1787<p>The system image included in the downloadable platform provides these
1788built-in applications:</p>
1789
1790<table style="border:0;padding-bottom:0;margin-bottom:0;">
1791<tr>
1792<td style="border:0;padding-bottom:0;margin-bottom:0;">
1793<ul>
1794<li>API Demos</li>
1795<li>Browser</li>
1796<li>Calculator</li>
Scott Maine1e9e932011-10-13 23:36:19 -07001797<li>Calendar</li>
Scott Main1d6f70c2011-10-06 22:57:25 -07001798<li>Camera</li>
1799<li>Clock</li>
1800<li>Custom Locale</li>
1801<li>Dev Tools</li>
1802<li>Downloads</li>
1803<li>Email</li>
1804<li>Gallery</li>
1805</ul>
1806</td>
1807<td style="border:0;padding-bottom:0;margin-bottom:0;padding-left:5em;">
1808<ul>
1809<li>Gestures Builder</li>
1810<li>Messaging</li>
1811<li>Music</li>
1812<li>People</li>
1813<li>Phone</li>
1814<li>Search</li>
1815<li>Settings</li>
Scott Maine1e9e932011-10-13 23:36:19 -07001816<li>Speech Recorder</li>
Scott Main1d6f70c2011-10-06 22:57:25 -07001817<li>Speech Recorder</li>
1818<li>Widget Preview</li>
1819</ul>
1820</td>
1821</tr>
1822</table>
1823
1824
1825<h2 id="locs" style="margin-top:.75em;">Locales</h2>
1826
Scott Maine1e9e932011-10-13 23:36:19 -07001827<p>The system image included in the downloadable SDK platform provides a variety of built-in
1828locales. In some cases, region-specific strings are available for the locales. In other cases, a
1829default version of the language is used. The languages that are available in the Android 3.0 system
1830image are listed below (with <em>language</em>_<em>country/region</em> locale descriptor).</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001831
1832<table style="border:0;padding-bottom:0;margin-bottom:0;">
1833<tr>
1834<td style="border:0;padding-bottom:0;margin-bottom:0;">
1835<ul>
1836<li>Arabic, Egypt (ar_EG)</li>
1837<li>Arabic, Israel (ar_IL)</li>
1838<li>Bulgarian, Bulgaria (bg_BG)</li>
1839<li>Catalan, Spain (ca_ES)</li>
1840<li>Czech, Czech Republic (cs_CZ)</li>
1841<li>Danish, Denmark(da_DK)</li>
1842<li>German, Austria (de_AT)</li>
1843<li>German, Switzerland (de_CH)</li>
1844<li>German, Germany (de_DE)</li>
1845<li>German, Liechtenstein (de_LI)</li>
1846<li>Greek, Greece (el_GR)</li>
1847<li>English, Australia (en_AU)</li>
1848<li>English, Canada (en_CA)</li>
1849<li>English, Britain (en_GB)</li>
1850<li>English, Ireland (en_IE)</li>
1851<li>English, India (en_IN)</li>
1852<li>English, New Zealand (en_NZ)</li>
1853<li>English, Singapore(en_SG)</li>
1854<li>English, US (en_US)</li>
1855<li>English, Zimbabwe (en_ZA)</li>
1856<li>Spanish (es_ES)</li>
1857<li>Spanish, US (es_US)</li>
1858<li>Finnish, Finland (fi_FI)</li>
1859<li>French, Belgium (fr_BE)</li>
1860<li>French, Canada (fr_CA)</li>
1861<li>French, Switzerland (fr_CH)</li>
1862<li>French, France (fr_FR)</li>
1863<li>Hebrew, Israel (he_IL)</li>
1864<li>Hindi, India (hi_IN)</li>
1865</ul>
1866</td>
1867<td style="border:0;padding-bottom:0;margin-bottom:0;padding-left:5em;">
1868<li>Croatian, Croatia (hr_HR)</li>
1869<li>Hungarian, Hungary (hu_HU)</li>
1870<li>Indonesian, Indonesia (id_ID)</li>
1871<li>Italian, Switzerland (it_CH)</li>
1872<li>Italian, Italy (it_IT)</li>
1873<li>Japanese (ja_JP)</li>
1874<li>Korean (ko_KR)</li>
1875<li>Lithuanian, Lithuania (lt_LT)</li>
1876<li>Latvian, Latvia (lv_LV)</li>
1877<li>Norwegian bokmål, Norway (nb_NO)</li>
1878<li>Dutch, Belgium (nl_BE)</li>
1879<li>Dutch, Netherlands (nl_NL)</li>
1880<li>Polish (pl_PL)</li>
1881<li>Portuguese, Brazil (pt_BR)</li>
1882<li>Portuguese, Portugal (pt_PT)</li>
1883<li>Romanian, Romania (ro_RO)</li>
1884<li>Russian (ru_RU)</li></li>
1885<li>Slovak, Slovakia (sk_SK)</li>
1886<li>Slovenian, Slovenia (sl_SI)</li>
1887<li>Serbian (sr_RS)</li>
1888<li>Swedish, Sweden (sv_SE)</li>
1889<li>Thai, Thailand (th_TH)</li>
1890<li>Tagalog, Philippines (tl_PH)</li>
1891<li>Turkish, Turkey (tr_TR)</li>
1892<li>Ukrainian, Ukraine (uk_UA)</li>
1893<li>Vietnamese, Vietnam (vi_VN)</li>
1894<li>Chinese, PRC (zh_CN)</li>
1895<li>Chinese, Taiwan (zh_TW)</li>
1896</td>
1897</tr>
1898</table>
1899
1900<p class="note"><strong>Note:</strong> The Android platform may support more
1901locales than are included in the SDK system image. All of the supported locales
1902are available in the <a href="http://source.android.com/">Android Open Source
1903Project</a>.</p>
1904
1905<h2 id="skins">Emulator Skins</h2>
1906
Scott Maine1e9e932011-10-13 23:36:19 -07001907<p>The downloadable platform includes the following emulator skins:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001908
1909<ul>
1910 <li>
Scott Maine1e9e932011-10-13 23:36:19 -07001911 QVGA (240x320, low density, small screen)
1912 </li>
1913 <li>
1914 WQVGA400 (240x400, low density, normal screen)
1915 </li>
1916 <li>
1917 WQVGA432 (240x432, low density, normal screen)
1918 </li>
1919 <li>
1920 HVGA (320x480, medium density, normal screen)
1921 </li>
1922 <li>
1923 WVGA800 (480x800, high density, normal screen)
1924 </li>
1925 <li>
1926 WVGA854 (480x854 high density, normal screen)
1927 </li>
1928 <li>
1929 WXGA720 (1280x720, extra-high density, normal screen) <span class="new">new</span>
1930 </li>
1931 <li>
1932 WSVGA (1024x600, medium density, large screen) <span class="new">new</span>
1933 </li>
1934 <li>
1935 WXGA (1280x800, medium density, xlarge screen)
Scott Main1d6f70c2011-10-06 22:57:25 -07001936 </li>
1937</ul>
1938
Scott Maine1e9e932011-10-13 23:36:19 -07001939<p>To test your application on an emulator that represents the latest Android device, you can create
1940an AVD with the new WXGA720 skin (it's an xhdpi, normal screen device). Note that the emulator
1941currently doesn't support the new on-screen navigation bar for devices without hardware navigation
1942buttons, so when using this skin, you must use keyboard keys <em>Home</em> for the Home button,
1943<em>ESC</em> for the Back button, and <em>F2</em> or <em>Page-up</em> for the Menu button.</p>
1944
1945<p>However, due to performance issues in the emulator when running high-resolution screens such as
1946the one for the WXGA720 skin, we recommend that you primarily use the traditional WVGA800 skin
1947(hdpi, normal screen) to test your application.</p>
1948