blob: e3b13c847cdd859b3c189aeea562f022112f17b7 [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-level">API Level</a></li>
15 <li><a href="#apps">Built-in Applications</a></li>
16 <li><a href="#locs">Locales</a></li>
17 <li><a href="#skins">Emulator Skins</a></li>
18</ol>
19
20<h2>Reference</h2>
21<ol>
22<li><a
23href="{@docRoot}sdk/api_diff/14/changes.html">API
24Differences Report &raquo;</a> </li>
25</ol>
26
27</div>
28</div>
29
30
31<p><em>API Level:</em>&nbsp;<strong>{@sdkPlatformApiLevel}</strong></p>
32
Scott Main423aca12011-10-17 16:31:11 -070033<p>Android 4.0 is a major platform release that adds a variety of new features for users and app
34developers. Besides all the new features and APIs discussed below, Android 4.0 is an important
35platform release because it brings the extensive set of APIs and Holographic themes from Android 3.x
36to smaller screens. As an app developer, you now have a single platform and unified API framework
37that enables you to develop and publish your application with a single APK that provides an
38optimized user experience for handsets, tablets, and more, when running the same version of
39Android&mdash;Android 4.0 (API level 14) or greater. </p>
Scott Main1d6f70c2011-10-06 22:57:25 -070040
Scott Main423aca12011-10-17 16:31:11 -070041<p>The Android {@sdkPlatformVersion} platform is available as a
42downloadable component for the Android SDK so you can begin developing and testing your
43applications on Android 4.0 with the Android emulator. The downloadable platform includes
Scott Main1d6f70c2011-10-06 22:57:25 -070044an Android library and system image, as well as a set of emulator skins and
Scott Main423aca12011-10-17 16:31:11 -070045more. The downloadable platform does not include any external libraries.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -070046
47<p>To start developing or testing against Android {@sdkPlatformVersion},
48use the Android SDK Manager to download the platform into your SDK. For more
49information, see <a href="{@docRoot}sdk/adding-components.html">Adding SDK
50Components</a>. If you are new to Android, <a
51href="{@docRoot}sdk/index.html">download the SDK Starter Package</a> first.</p>
52
Scott Main1d6f70c2011-10-06 22:57:25 -070053<p class="note"><strong>Reminder:</strong> If you've already published an
54Android application, please test your application on Android {@sdkPlatformVersion} as
55soon as possible to be sure your application provides the best
56experience possible on the latest Android-powered devices.</p>
57
Scott Main423aca12011-10-17 16:31:11 -070058<p>For a high-level overview of the new user and developer features in Android 4.0, see the
Scott Maine1e9e932011-10-13 23:36:19 -070059<a href="http://developer.android.com/sdk/android-4.0-highlights.html">Platform Highlights</a>.</p>
60
Scott Main1d6f70c2011-10-06 22:57:25 -070061
Scott Main423aca12011-10-17 16:31:11 -070062
Scott Main1d6f70c2011-10-06 22:57:25 -070063<h2 id="relnotes">Revisions</h2>
64
65<p>To determine what revision of the Android {@sdkPlatformVersion} platform you
66have installed, refer to the "Installed Packages" listing in the Android SDK Manager.</p>
67
Joe Fernandez890f7ea2011-11-28 17:00:27 -080068<p class="caution"><strong>Important:</strong> To download the new Android
694.0 system components from the Android SDK Manager, you must first update the
70SDK tools to revision 14 or later and restart the Android SDK Manager. If you do not,
71the Android 4.0 system components will not be available for download.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -070072
73<div class="toggle-content opened" style="padding-left:1em;">
74
75 <p><a href="#" onclick="return toggleContent(this)">
76 <img src="{@docRoot}assets/images/triangle-opened.png"
77class="toggle-content-img" alt="" />
Joe Fernandez890f7ea2011-11-28 17:00:27 -080078 Android {@sdkPlatformVersion}, Revision 2</a> <em>(December 2011)</em>
79 </a></p>
80
81 <div class="toggle-content-toggleme" style="padding-left:2em;">
82 <p>Maintenance update. The system version is 4.0.2.</p>
83 <dl>
84 <dt>Dependencies:</dt>
85 <dd>SDK Tools r14 or higher is required.</dd>
86 </dl>
87 </div>
88</div>
89
90<div class="toggle-content closed" style="padding-left:1em;">
91
92 <p><a href="#" onclick="return toggleContent(this)">
93 <img src="{@docRoot}assets/images/triangle-closed.png"
94class="toggle-content-img" alt="" />
Scott Main1d6f70c2011-10-06 22:57:25 -070095 Android {@sdkPlatformVersion}, Revision 1</a> <em>(October 2011)</em>
96 </a></p>
97
98 <div class="toggle-content-toggleme" style="padding-left:2em;">
Joe Fernandez890f7ea2011-11-28 17:00:27 -080099 <p>Initial release. The system version is 4.0.1.</p>
100 <dl>
101 <dt>Dependencies:</dt>
102 <dd>SDK Tools r14 or higher is required.</dd>
103 </dl>
Scott Main1d6f70c2011-10-06 22:57:25 -0700104 </div>
105</div>
106
107
108<h2 id="api">API Overview</h2>
109
110<p>The sections below provide a technical overview of new APIs in Android 4.0.</p>
111
112<div class="toggle-content closed" style="padding-left:1em;">
113
114 <p><a href="#" onclick="return toggleContent(this)">
115 <img src="{@docRoot}assets/images/triangle-closed.png"
116class="toggle-content-img" alt="" />
117 <strong>Table of Contents</strong>
118 </a></p>
119
120 <div class="toggle-content-toggleme" style="padding-left:2em;">
121 <ol class="toc" style="margin-left:-1em">
Scott Main423aca12011-10-17 16:31:11 -0700122 <li><a href="#Contacts">Social APIs in Contacts Provider</a></li>
Scott Maine1e9e932011-10-13 23:36:19 -0700123 <li><a href="#Calendar">Calendar Provider</a></li>
124 <li><a href="#Voicemail">Voicemail Provider</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700125 <li><a href="#Multimedia">Multimedia</a></li>
Scott Main423aca12011-10-17 16:31:11 -0700126 <li><a href="#Camera">Camera</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700127 <li><a href="#AndroidBeam">Android Beam (NDEF Push with NFC)</a></li>
Scott Maine09743272011-10-14 11:25:46 -0700128 <li><a href="#WiFiDirect">Wi-Fi Direct</a></li>
Scott Main423aca12011-10-17 16:31:11 -0700129 <li><a href="#Bluetooth">Bluetooth Health Devices</a></li>
130 <li><a href="#A11y">Accessibility</a></li>
131 <li><a href="#SpellChecker">Spell Checker Services</a></li>
132 <li><a href="#TTS">Text-to-speech Engines</a></li>
Scott Maine09743272011-10-14 11:25:46 -0700133 <li><a href="#NetworkUsage">Network Usage</a></li>
Scott Maine1e9e932011-10-13 23:36:19 -0700134 <li><a href="#RenderScript">RenderScript</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700135 <li><a href="#Enterprise">Enterprise</a></li>
Scott Maine1e9e932011-10-13 23:36:19 -0700136 <li><a href="#Sensors">Device Sensors</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700137 <li><a href="#ActionBar">Action Bar</a></li>
138 <li><a href="#UI">User Interface and Views</a></li>
Scott Main423aca12011-10-17 16:31:11 -0700139 <li><a href="#Input">Input Framework</a></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700140 <li><a href="#Properties">Properties</a></li>
141 <li><a href="#HwAccel">Hardware Acceleration</a></li>
142 <li><a href="#Jni">JNI Changes</a></li>
143 <li><a href="#WebKit">WebKit</a></li>
144 <li><a href="#Permissions">Permissions</a></li>
145 <li><a href="#DeviceFeatures">Device Features</a></li>
146 </ol>
147 </div>
148</div>
149
150
151
152
153
Scott Main423aca12011-10-17 16:31:11 -0700154<h3 id="Contacts">Social APIs in Contacts Provider</h3>
Scott Main1d6f70c2011-10-06 22:57:25 -0700155
Scott Main423aca12011-10-17 16:31:11 -0700156<p>The contact APIs defined by the {@link android.provider.ContactsContract} provider have been
157extended to support new social-oriented features such as a personal profile for the device owner and
158the ability for users to invite individual contacts to social networks that are installed on the
159device.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700160
161
162<h4>User Profile</h4>
163
164<p>Android now includes a personal profile that represents the device owner, as defined by the
Scott Maine1e9e932011-10-13 23:36:19 -0700165{@link android.provider.ContactsContract.Profile} table. Social apps that maintain a user identity
166can contribute to the user's profile data by creating a new {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700167android.provider.ContactsContract.RawContacts} entry within the {@link
168android.provider.ContactsContract.Profile}. That is, raw contacts that represent the device user do
169not belong in the traditional raw contacts table defined by the {@link
170android.provider.ContactsContract.RawContacts} Uri; instead, you must add a profile raw contact in
171the table at {@link android.provider.ContactsContract.Profile#CONTENT_RAW_CONTACTS_URI}. Raw
Scott Maine1e9e932011-10-13 23:36:19 -0700172contacts in this table are then aggregated into the single user-visible profile labeled "Me".</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700173
174<p>Adding a new raw contact for the profile requires the {@link
175android.Manifest.permission#WRITE_PROFILE} permission. Likewise, in order to read from the profile
176table, you must request the {@link android.Manifest.permission#READ_PROFILE} permission. However,
Scott Main47bc0fe2011-10-19 12:01:16 -0700177most apps should not need to read the user profile, even when contributing data to the
Scott Maine1e9e932011-10-13 23:36:19 -0700178profile. Reading the user profile is a sensitive permission and you should expect users to be
179skeptical of apps that request it.</p>
180
Scott Main1d6f70c2011-10-06 22:57:25 -0700181
Scott Main1d6f70c2011-10-06 22:57:25 -0700182<h4>Invite Intent</h4>
183
Scott Maine1e9e932011-10-13 23:36:19 -0700184<p>The {@link android.provider.ContactsContract.Intents#INVITE_CONTACT} intent action allows an app
185to invoke an action that indicates the user wants to add a contact to a social network. The app
186receiving the app uses it to invite the specified contact to that
187social network. Most apps will be on the receiving-end of this operation. For example, the
188built-in People app invokes the invite intent when the user selects "Add connection" for a specific
189social app that's listed in a person's contact details.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700190
Scott Maine1e9e932011-10-13 23:36:19 -0700191<p>To make your app visible as in the "Add connection" list, your app must provide a sync adapter to
192sync contact information from your social network. You must then indicate to the system that your
193app responds to the {@link android.provider.ContactsContract.Intents#INVITE_CONTACT} intent by
194adding the {@code inviteContactActivity} attribute to your app’s sync configuration file, with a
195fully-qualified name of the activity that the system should start when sending the invite intent.
196The activity that starts can then retrieve the URI for the contact in question from the intent’s
197data and perform the necessary work to invite that contact to the network or add the person to the
198user’s connections.</p>
199
200<p>See the <a href="{@docRoot}resources/samples/SampleSyncAdapter/index.html">Sample Sync
201Adapter</a> app for an example (specifically, see the <a
202href="{@docRoot}resources/samples/SampleSyncAdapter/res/xml-v14/contacts.html">contacts.xml</a>
203file).</p>
204
Scott Main1d6f70c2011-10-06 22:57:25 -0700205
Scott Main423aca12011-10-17 16:31:11 -0700206<h4>Large photos</h4>
207
208<p>Android now supports high resolution photos for contacts. Now, when you push a photo into a
209contact record, the system processes it into both a 96x96 thumbnail (as it has previously) and a
210256x256 "display photo" that's stored in a new file-based photo store (the exact dimensions that the
211system chooses may vary in the future). You can add a large photo to a contact by putting a large
212photo in the usual {@link android.provider.ContactsContract.CommonDataKinds.Photo#PHOTO} column of a
213data row, which the system will then process into the appropriate thumbnail and display photo
214records.</p>
215
216
Scott Main1d6f70c2011-10-06 22:57:25 -0700217<h4>Contact Usage Feedback</h4>
218
219<p>The new {@link android.provider.ContactsContract.DataUsageFeedback} APIs allow you to help track
220how often the user uses particular methods of contacting people, such as how often the user uses
221each phone number or e-mail address. This information helps improve the ranking for each contact
Scott Maine1e9e932011-10-13 23:36:19 -0700222method associated with each person and provide better suggestions for contacting each person.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700223
224
225
226
227
Scott Maine1e9e932011-10-13 23:36:19 -0700228<h3 id="Calendar">Calendar Provider</h3>
Scott Main1d6f70c2011-10-06 22:57:25 -0700229
Scott Mainb57769a2011-10-17 11:20:49 -0700230<p>The new calendar APIs allow you to read, add, modify and delete calendars, events, attendees,
231reminders and alerts, which are stored in the Calendar Provider.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700232
Scott Maine1e9e932011-10-13 23:36:19 -0700233<p>A variety of apps and widgets can use these APIs to read and modify calendar events. However,
234some of the most compelling use cases are sync adapters that synchronize the user's calendar from
Scott Mainb57769a2011-10-17 11:20:49 -0700235other calendar services with the Calendar Provider, in order to offer a unified location for all the
236user's events. Google Calendar events, for example, are synchronized with the Calendar Provider by
237the Google Calendar Sync Adapter, allowing these events to be viewed with Android's built-in
Scott Maine1e9e932011-10-13 23:36:19 -0700238Calendar app.</p>
239
240<p>The data model for calendars and event-related information in the Calendar Provider is
241defined by {@link android.provider.CalendarContract}. All the user’s calendar data is stored in a
242number of tables defined by various subclasses of {@link android.provider.CalendarContract}:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700243
244<ul>
245<li>The {@link android.provider.CalendarContract.Calendars} table holds the calendar-specific
246information. Each row in this table contains the details for a single calendar, such as the name,
247color, sync information, and so on.</li>
248
249<li>The {@link android.provider.CalendarContract.Events} table holds event-specific information.
Scott Maine1e9e932011-10-13 23:36:19 -0700250Each row in this table contains the information for a single event, such as the
251event title, location, start time, end time, and so on. The event can occur one time or recur
252multiple times. Attendees, reminders, and extended properties are stored in separate tables and
253use the event’s {@code _ID} to link them with the event.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700254
255<li>The {@link android.provider.CalendarContract.Instances} table holds the start and end time for
256occurrences of an event. Each row in this table represents a single occurrence. For one-time events
257there is a one-to-one mapping of instances to events. For recurring events, multiple rows are
258automatically generated to correspond to the multiple occurrences of that event.</li>
259
260<li>The {@link android.provider.CalendarContract.Attendees} table holds the event attendee or guest
261information. Each row represents a single guest of an event. It specifies the type of guest the
Scott Maine1e9e932011-10-13 23:36:19 -0700262person is and the person’s response for the event.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700263
264<li>The {@link android.provider.CalendarContract.Reminders} table holds the alert/notification data.
265Each row represents a single alert for an event. An event can have multiple reminders. The number of
Scott Maine1e9e932011-10-13 23:36:19 -0700266reminders per event is specified in {@code MAX_REMINDERS}, which is set by the sync adapter that
267owns the given calendar. Reminders are specified in number-of-minutes before the event is
268scheduled and specify an alarm method such as to use an alert, email, or SMS to remind
269the user.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700270
271<li>The {@link android.provider.CalendarContract.ExtendedProperties} table hold opaque data fields
Scott Maine1e9e932011-10-13 23:36:19 -0700272used by the sync adapter. The provider takes no action with items in this table except to delete
273them when their related events are deleted.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700274</ul>
275
Scott Maine1e9e932011-10-13 23:36:19 -0700276<p>To access a user’s calendar data with the Calendar Provider, your application must request
277the {@link android.Manifest.permission#READ_CALENDAR} permission (for read access) and
278{@link android.Manifest.permission#WRITE_CALENDAR} (for write access).</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700279
Scott Main1d6f70c2011-10-06 22:57:25 -0700280
Scott Maine1e9e932011-10-13 23:36:19 -0700281<h4>Event intent</h4>
282
Scott Maincea58532011-10-27 09:11:14 -0700283<p>If all you want to do is add an event to the user’s calendar, you can use an {@link
284android.content.Intent#ACTION_INSERT} intent with the data defined by {@link
285android.provider.CalendarContract.Events#CONTENT_URI Events.CONTENT_URI} in order to start an
286activity in the Calendar app that creates new events. Using the intent does not require any
287permission and you can specify event details with the following extras:</p>
Scott Maine1e9e932011-10-13 23:36:19 -0700288
289<ul>
290 <li>{@link android.provider.CalendarContract.EventsColumns#TITLE Events.TITLE}: Name for the
291event</li>
292 <li>{@link
293android.provider.CalendarContract#EXTRA_EVENT_BEGIN_TIME CalendarContract.EXTRA_EVENT_BEGIN_TIME}:
294Event begin time in milliseconds from the
295epoch</li>
296 <li>{@link
297android.provider.CalendarContract#EXTRA_EVENT_END_TIME CalendarContract.EXTRA_EVENT_END_TIME}: Event
298end time in milliseconds from the epoch</li>
299 <li>{@link android.provider.CalendarContract.EventsColumns#EVENT_LOCATION Events.EVENT_LOCATION}:
300Location of the event</li>
301 <li>{@link android.provider.CalendarContract.EventsColumns#DESCRIPTION Events.DESCRIPTION}: Event
302description</li>
303 <li>{@link android.content.Intent#EXTRA_EMAIL Intent.EXTRA_EMAIL}: Email addresses of those to
304invite</li>
305 <li>{@link android.provider.CalendarContract.EventsColumns#RRULE Events.RRULE}: The recurrence
306rule for the event</li>
307 <li>{@link android.provider.CalendarContract.EventsColumns#ACCESS_LEVEL Events.ACCESS_LEVEL}:
308Whether the event is private or public</li>
309 <li>{@link android.provider.CalendarContract.EventsColumns#AVAILABILITY Events.AVAILABILITY}:
310Whether the time period of this event allows for other events to be scheduled at the same time</li>
311</ul>
312
313
314
315
316<h3 id="Voicemail">Voicemail Provider</h3>
317
Scott Main423aca12011-10-17 16:31:11 -0700318<p>The new Voicemail Provider allows applications to add voicemails to the
319device, in order to present all the user's voicemails in a single visual presentation. For instance,
320it’s possible that a user has multiple voicemail sources, such as
321one from the phone’s service provider and others from VoIP or other alternative voice
322services. These apps can use the Voicemail Provider APIs to add their voicemails to the device. The
323built-in Phone application then presents all voicemails to the user in a unified presentation.
Scott Maine1e9e932011-10-13 23:36:19 -0700324Although the system’s Phone application is the only application that can read all the voicemails,
325each application that provides voicemails can read those that it has added to the system (but cannot
326read voicemails from other services).</p>
327
Scott Main423aca12011-10-17 16:31:11 -0700328<p>Because the APIs currently do not allow third-party apps to read all the voicemails from the
329system, the only third-party apps that should use the voicemail APIs are those that have voicemail
330to deliver to the user.</p>
331
Scott Maine1e9e932011-10-13 23:36:19 -0700332<p>The {@link android.provider.VoicemailContract} class defines the content provider for the
Scott Main423aca12011-10-17 16:31:11 -0700333Voicemail Provder. The subclasses {@link android.provider.VoicemailContract.Voicemails} and {@link
334android.provider.VoicemailContract.Status} provide tables in which apps can
Scott Maine1e9e932011-10-13 23:36:19 -0700335insert voicemail data for storage on the device. For an example of a voicemail provider app, see the
Scott Mainb57769a2011-10-17 11:20:49 -0700336<a href="{@docRoot}resources/samples/VoicemailProviderDemo/index.html">Voicemail Provider
Scott Maine1e9e932011-10-13 23:36:19 -0700337Demo</a>.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700338
339
340
341
Scott Main423aca12011-10-17 16:31:11 -0700342
343<h3 id="Multimedia">Multimedia</h3>
344
345<p>Android 4.0 adds several new APIs for applications that interact with media such as photos,
346videos, and music.</p>
347
348
349<h4>Media Effects</h4>
350
351<p>A new media effects framework allows you to apply a variety of visual effects to images and
352videos. For example, image effects allow you to easily fix red-eye, convert an image to grayscale,
353adjust brightness, adjust saturation, rotate an image, apply a fisheye effect, and much more. The
354system performs all effects processing on the GPU to obtain maximum performance.</p>
355
356<p>For maximum performance, effects are applied directly to OpenGL textures, so your application
357must have a valid OpenGL context before it can use the effects APIs. The textures to which you apply
358effects may be from bitmaps, videos or even the camera. However, there are certain restrictions that
359textures must meet:</p>
360<ol>
361<li>They must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture image</li>
362<li>They must contain at least one mipmap level</li>
363</ol>
364
365<p>An {@link android.media.effect.Effect} object defines a single media effect that you can apply to
366an image frame. The basic workflow to create an {@link android.media.effect.Effect} is:</p>
367
368<ol>
369<li>Call {@link android.media.effect.EffectContext#createWithCurrentGlContext
370EffectContext.createWithCurrentGlContext()} from your OpenGL ES 2.0 context.</li>
371<li>Use the returned {@link android.media.effect.EffectContext} to call {@link
372android.media.effect.EffectContext#getFactory EffectContext.getFactory()}, which returns an instance
373of {@link android.media.effect.EffectFactory}.</li>
374<li>Call {@link android.media.effect.EffectFactory#createEffect createEffect()}, passing it an
375effect name from @link android.media.effect.EffectFactory}, such as {@link
376android.media.effect.EffectFactory#EFFECT_FISHEYE} or {@link
377android.media.effect.EffectFactory#EFFECT_VIGNETTE}.</li>
378</ol>
379
380<p>You can adjust an effect’s parameters by calling {@link android.media.effect.Effect#setParameter
381setParameter()} and passing a parameter name and parameter value. Each type of effect accepts
382different parameters, which are documented with the effect name. For example, {@link
383android.media.effect.EffectFactory#EFFECT_FISHEYE} has one parameter for the {@code scale} of the
384distortion.</p>
385
386<p>To apply an effect on a texture, call {@link android.media.effect.Effect#apply apply()} on the
387{@link
388android.media.effect.Effect} and pass in the input texture, it’s width and height, and the output
389texture. The input texture must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture
390image (usually done by calling the {@link android.opengl.GLES20#glTexImage2D glTexImage2D()}
391function). You may provide multiple mipmap levels. If the output texture has not been bound to a
392texture image, it will be automatically bound by the effect as a {@link
393android.opengl.GLES20#GL_TEXTURE_2D} and with one mipmap level (0), which will have the same
394size as the input.</p>
395
396<p>All effects listed in {@link android.media.effect.EffectFactory} are guaranteed to be supported.
397However, some additional effects available from external libraries are not supported by all devices,
398so you must first check if the desired effect from the external library is supported by calling
399{@link android.media.effect.EffectFactory#isEffectSupported isEffectSupported()}.</p>
400
401
402<h4>Remote control client</h4>
403
404<p>The new {@link android.media.RemoteControlClient} allows media players to enable playback
405controls from remote control clients such as the device lock screen. Media players can also expose
406information about the media currently playing for display on the remote control, such as track
407information and album art.</p>
408
409<p>To enable remote control clients for your media player, instantiate a {@link
410android.media.RemoteControlClient} with its constructor, passing it a {@link
411android.app.PendingIntent} that broadcasts {@link
412android.content.Intent#ACTION_MEDIA_BUTTON}. The intent must also declare the explicit {@link
413android.content.BroadcastReceiver} component in your app that handles the {@link
414android.content.Intent#ACTION_MEDIA_BUTTON} event.</p>
415
416<p>To declare which media control inputs your player can handle, you must call {@link
417android.media.RemoteControlClient#setTransportControlFlags setTransportControlFlags()} on your
418{@link android.media.RemoteControlClient}, passing a set of {@code FLAG_KEY_MEDIA_*} flags, such as
419{@link android.media.RemoteControlClient#FLAG_KEY_MEDIA_PREVIOUS} and {@link
420android.media.RemoteControlClient#FLAG_KEY_MEDIA_NEXT}.</p>
421
422<p>You must then register your {@link android.media.RemoteControlClient} by passing it to {@link
423android.media.AudioManager#registerRemoteControlClient MediaManager.registerRemoteControlClient()}.
424Once registered, the broadcast receiver you declared when you instantiated the {@link
425android.media.RemoteControlClient} will receive {@link android.content.Intent#ACTION_MEDIA_BUTTON}
426events when a button is pressed from a remote control. The intent you receive includes the {@link
427android.view.KeyEvent} for the media key pressed, which you can retrieve from the intent with {@link
428android.content.Intent#getParcelableExtra getParcelableExtra(Intent.EXTRA_KEY_EVENT)}.</p>
429
430<p>To display information on the remote control about the media playing, call {@link
431android.media.RemoteControlClient#editMetadata editMetaData()} and add metadata to the returned
432{@link android.media.RemoteControlClient.MetadataEditor}. You can supply a bitmap for media artwork,
433numerical information such as elapsed time, and text information such as the track title. For
434information on available keys see the {@code METADATA_KEY_*} flags in {@link
435android.media.MediaMetadataRetriever}.</p>
436
437<p>For a sample implementation, see the <a
438href="{@docRoot}resources/samples/RandomMusicPlayer/index.html">Random Music Player</a>, which
439provides compatibility logic such that it enables the remote control client on Android 4.0
440devices while continuing to support devices back to Android 2.1.</p>
441
442
443<h4>Media player</h4>
444
445<ul>
446<li>Streaming online media from {@link android.media.MediaPlayer} now requires the {@link
447android.Manifest.permission#INTERNET} permission. If you use {@link android.media.MediaPlayer} to
448play content from the Internet, be sure to add the {@link android.Manifest.permission#INTERNET}
449permission to your manifest or else your media playback will not work beginning with Android
4504.0.</li>
451
452<li>{@link android.media.MediaPlayer#setSurface(Surface) setSurface()} allows you define a {@link
453android.view.Surface} to behave as the video sink.</li>
454
455<li>{@link android.media.MediaPlayer#setDataSource(Context,Uri,Map) setDataSource()} allows you to
456send additional HTTP headers with your request, which can be useful for HTTP(S) live streaming</li>
457
458<li>HTTP(S) live streaming now respects HTTP cookies across requests</li>
459</ul>
460
461
462<h4>Media types</h4>
463
464<p>Android 4.0 adds support for:</p>
465<ul>
466<li>HTTP/HTTPS live streaming protocol version 3 </li>
467<li>ADTS raw AAC audio encoding</li>
468<li>WEBP images</li>
469<li>Matroska video</li>
470</ul>
471<p>For more info, see <a href="{@docRoot}guide/appendix/media-formats.html">Supported Media
472Formats</a>.</p>
473
474
475
476
477
Scott Main1d6f70c2011-10-06 22:57:25 -0700478<h3 id="Camera">Camera</h3>
479
Scott Maine1e9e932011-10-13 23:36:19 -0700480<p>The {@link android.hardware.Camera} class now includes APIs for detecting faces and controlling
481focus and metering areas.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700482
Scott Main1d6f70c2011-10-06 22:57:25 -0700483
Scott Maine1e9e932011-10-13 23:36:19 -0700484<h4>Face detection</h4>
485
486<p>Camera apps can now enhance their abilities with Android’s face detection APIs, which not
487only detect the face of a subject, but also specific facial features, such as the eyes and mouth.
488</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700489
490<p>To detect faces in your camera application, you must register a {@link
491android.hardware.Camera.FaceDetectionListener} by calling {@link
492android.hardware.Camera#setFaceDetectionListener setFaceDetectionListener()}. You can then start
493your camera surface and start detecting faces by calling {@link
494android.hardware.Camera#startFaceDetection}.</p>
495
Scott Maine1e9e932011-10-13 23:36:19 -0700496<p>When the system detects one or more faces in the camera scene, it calls the {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700497android.hardware.Camera.FaceDetectionListener#onFaceDetection onFaceDetection()} callback in your
498implementation of {@link android.hardware.Camera.FaceDetectionListener}, including an array of
499{@link android.hardware.Camera.Face} objects.</p>
500
501<p>An instance of the {@link android.hardware.Camera.Face} class provides various information about
Scott Maine1e9e932011-10-13 23:36:19 -0700502the face detected, including:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700503<ul>
504<li>A {@link android.graphics.Rect} that specifies the bounds of the face, relative to the camera's
505current field of view</li>
Scott Mainb57769a2011-10-17 11:20:49 -0700506<li>An integer betwen 1 and 100 that indicates how confident the system is that the object is a
Scott Maine1e9e932011-10-13 23:36:19 -0700507human face</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700508<li>A unique ID so you can track multiple faces</li>
509<li>Several {@link android.graphics.Point} objects that indicate where the eyes and mouth are
510located</li>
511</ul>
512
Scott Mainb57769a2011-10-17 11:20:49 -0700513<p class="note"><strong>Note:</strong> Face detection may not be supported on some
514devices, so you should check by calling {@link
515android.hardware.Camera.Parameters#getMaxNumDetectedFaces()} and ensure the return
516value is greater than zero. Also, some devices may not support identification of eyes and mouth,
517in which case, those fields in the {@link android.hardware.Camera.Face} object will be null.</p>
518
Scott Maine1e9e932011-10-13 23:36:19 -0700519
520<h4>Focus and metering areas</h4>
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700521
Scott Maine1e9e932011-10-13 23:36:19 -0700522<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 -0700523balance
Scott Maine1e9e932011-10-13 23:36:19 -0700524and auto-exposure. Both features use the new {@link android.hardware.Camera.Area} class to specify
525the region of the camera’s current view that should be focused or metered. An instance of the {@link
526android.hardware.Camera.Area} class defines the bounds of the area with a {@link
527android.graphics.Rect} and the area's weight&mdash;representing the level of importance of that
528area, relative to other areas in consideration&mdash;with an integer.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700529
530<p>Before setting either a focus area or metering area, you should first call {@link
531android.hardware.Camera.Parameters#getMaxNumFocusAreas} or {@link
532android.hardware.Camera.Parameters#getMaxNumMeteringAreas}, respectively. If these return zero, then
Scott Maine1e9e932011-10-13 23:36:19 -0700533the device does not support the corresponding feature.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700534
535<p>To specify the focus or metering areas to use, simply call {@link
536android.hardware.Camera.Parameters#setFocusAreas setFocusAreas()} or {@link
Scott Mainaea8d852011-11-02 12:05:51 -0700537android.hardware.Camera.Parameters#setMeteringAreas setMeteringAreas()}. Each take a {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700538java.util.List} of {@link android.hardware.Camera.Area} objects that indicate the areas to consider
539for focus or metering. For example, you might implement a feature that allows the user to set the
540focus area by touching an area of the preview, which you then translate to an {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700541android.hardware.Camera.Area} object and request that the camera focus on that area of the scene.
542The focus or exposure in that area will continually update as the scene in the area changes.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700543
544
Scott Mainb57769a2011-10-17 11:20:49 -0700545<h4>Continuous auto focus for photos</h4>
546
547<p>You can now enable continuous auto focusing (CAF) when taking photos. To enable CAF in your
548camera app, pass {@link android.hardware.Camera.Parameters#FOCUS_MODE_CONTINUOUS_PICTURE}
549to {@link android.hardware.Camera.Parameters#setFocusMode setFocusMode()}. When ready to capture
550a photo, call {@link android.hardware.Camera#autoFocus autoFocus()}. Your {@link
551android.hardware.Camera.AutoFocusCallback} immediately receives a callback to indicate whether
Scott Main423aca12011-10-17 16:31:11 -0700552focus was achieved. To resume CAF after receiving the callback, you must call {@link
Scott Mainb57769a2011-10-17 11:20:49 -0700553android.hardware.Camera#cancelAutoFocus()}.</p>
554
555<p class="note"><strong>Note:</strong> Continuous auto focus is also supported when capturing
556video, using {@link android.hardware.Camera.Parameters#FOCUS_MODE_CONTINUOUS_VIDEO}, which was
557added in API level 9.</p>
558
559
Scott Maine1e9e932011-10-13 23:36:19 -0700560<h4>Other camera features</h4>
561
Scott Mainb57769a2011-10-17 11:20:49 -0700562<ul>
Scott Maine1e9e932011-10-13 23:36:19 -0700563<li>While recording video, you can now call {@link android.hardware.Camera#takePicture
564takePicture()} to save a photo without interrupting the video session. Before doing so, you should
565call {@link android.hardware.Camera.Parameters#isVideoSnapshotSupported} to be sure the hardware
566supports it.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700567
Scott Mainb57769a2011-10-17 11:20:49 -0700568<li>You can now lock auto exposure and white balance with {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700569android.hardware.Camera.Parameters#setAutoExposureLock setAutoExposureLock()} and {@link
Scott Mainb57769a2011-10-17 11:20:49 -0700570android.hardware.Camera.Parameters#setAutoWhiteBalanceLock setAutoWhiteBalanceLock()} to prevent
Scott Main1d6f70c2011-10-06 22:57:25 -0700571these properties from changing.</li>
Scott Mainb57769a2011-10-17 11:20:49 -0700572
573<li>You can now call {@link android.hardware.Camera#setDisplayOrientation
574setDisplayOrientation()} while the camera preview is running. Previously, you could call this
575only before beginning the preview, but you can now change the orientation at any time.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700576</ul>
577
Scott Maine1e9e932011-10-13 23:36:19 -0700578
579<h4>Camera broadcast intents</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700580
581<ul>
Scott Maine1e9e932011-10-13 23:36:19 -0700582<li>{@link android.hardware.Camera#ACTION_NEW_PICTURE Camera.ACTION_NEW_PICTURE}:
583This indicates that the user has captured a new photo. The built-in Camera app invokes this
Scott Main1d6f70c2011-10-06 22:57:25 -0700584broadcast after a photo is captured and third-party camera apps should also broadcast this intent
585after capturing a photo.</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700586<li>{@link android.hardware.Camera#ACTION_NEW_VIDEO Camera.ACTION_NEW_VIDEO}:
587This indicates that the user has captured a new video. The built-in Camera app invokes this
Scott Main1d6f70c2011-10-06 22:57:25 -0700588broadcast after a video is recorded and third-party camera apps should also broadcast this intent
589after capturing a video.</li>
590</ul>
591
Scott Main1d6f70c2011-10-06 22:57:25 -0700592
Robert Ly6cf7d9a2011-10-12 15:30:35 -0700593
594
595
Scott Main1d6f70c2011-10-06 22:57:25 -0700596<h3 id="AndroidBeam">Android Beam (NDEF Push with NFC)</h3>
597
Scott Maine1e9e932011-10-13 23:36:19 -0700598<p>Android Beam is a new NFC feature that allows you to send NDEF messages from one device to
Scott Mainb57769a2011-10-17 11:20:49 -0700599another (a process also known as “NDEF Push"). The data transfer is initiated when two
Scott Main1d6f70c2011-10-06 22:57:25 -0700600Android-powered devices that support Android Beam are in close proximity (about 4 cm), usually with
601their backs touching. The data inside the NDEF message can contain any data that you wish to share
602between devices. For example, the People app shares contacts, YouTube shares videos, and Browser
603shares URLs using Android Beam.</p>
604
605<p>To transmit data between devices using Android Beam, you need to create an {@link
606android.nfc.NdefMessage} that contains the information you want to share while your activity is in
Scott Maine1e9e932011-10-13 23:36:19 -0700607the foreground. You must then pass the {@link android.nfc.NdefMessage} to the system in one of two
608ways:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700609
610<ul>
Scott Maine1e9e932011-10-13 23:36:19 -0700611<li>Define a single {@link android.nfc.NdefMessage} to push while in the activity:
Scott Main1d6f70c2011-10-06 22:57:25 -0700612<p>Call {@link android.nfc.NfcAdapter#setNdefPushMessage setNdefPushMessage()} at any time to set
Scott Maine1e9e932011-10-13 23:36:19 -0700613the message you want to send. For instance, you might call this method and pass it your {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700614android.nfc.NdefMessage} during your activity’s {@link android.app.Activity#onCreate onCreate()}
Scott Maine1e9e932011-10-13 23:36:19 -0700615method. Then, whenever Android Beam is activated with another device while the activity is in the
616foreground, the system sends the {@link android.nfc.NdefMessage} to the other device.</p></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700617
Scott Maine1e9e932011-10-13 23:36:19 -0700618<li>Define the {@link android.nfc.NdefMessage} to push at the time that Android Beam is initiated:
619<p>Implement {@link android.nfc.NfcAdapter.CreateNdefMessageCallback}, in which your
620implementation of the {@link
621android.nfc.NfcAdapter.CreateNdefMessageCallback#createNdefMessage createNdefMessage()}
Scott Main1d6f70c2011-10-06 22:57:25 -0700622method returns the {@link android.nfc.NdefMessage} you want to send. Then pass the {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700623android.nfc.NfcAdapter.CreateNdefMessageCallback} implementation to {@link
624android.nfc.NfcAdapter#setNdefPushMessageCallback setNdefPushMessageCallback()}.</p>
625<p>In this case, when Android Beam is activated with another device while your activity is in the
626foreground, the system calls {@link
627android.nfc.NfcAdapter.CreateNdefMessageCallback#createNdefMessage createNdefMessage()} to retrieve
628the {@link android.nfc.NdefMessage} you want to send. This allows you to define the {@link
629android.nfc.NdefMessage} to deliver only once Android Beam is initiated, in case the contents
630of the message might vary throughout the life of the activity.</p></li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700631</ul>
632
633<p>In case you want to run some specific code once the system has successfully delivered your NDEF
634message to the other device, you can implement {@link
635android.nfc.NfcAdapter.OnNdefPushCompleteCallback} and set it with {@link
636android.nfc.NfcAdapter#setOnNdefPushCompleteCallback setNdefPushCompleteCallback()}. The system will
637then call {@link android.nfc.NfcAdapter.OnNdefPushCompleteCallback#onNdefPushComplete
638onNdefPushComplete()} when the message is delivered.</p>
639
640<p>On the receiving device, the system dispatches NDEF Push messages in a similar way to regular NFC
641tags. The system invokes an intent with the {@link android.nfc.NfcAdapter#ACTION_NDEF_DISCOVERED}
642action to start an activity, with either a URL or a MIME type set according to the first {@link
643android.nfc.NdefRecord} in the {@link android.nfc.NdefMessage}. For the activity you want to
Scott Maine1e9e932011-10-13 23:36:19 -0700644respond, you can declare intent filters for the URLs or MIME types your app cares about. For more
Scott Main1d6f70c2011-10-06 22:57:25 -0700645information about Tag Dispatch see the <a
Scott Mainb57769a2011-10-17 11:20:49 -0700646href="{@docRoot}guide/topics/nfc/index.html#dispatch">NFC</a> developer guide.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700647
648<p>If you want your {@link android.nfc.NdefMessage} to carry a URI, you can now use the convenience
649method {@link android.nfc.NdefRecord#createUri createUri} to construct a new {@link
650android.nfc.NdefRecord} based on either a string or a {@link android.net.Uri} object. If the URI is
651a special format that you want your application to also receive during an Android Beam event, you
652should create an intent filter for your activity using the same URI scheme in order to receive the
653incoming NDEF message.</p>
654
Scott Mainb57769a2011-10-17 11:20:49 -0700655<p>You should also pass an “Android application record" with your {@link android.nfc.NdefMessage} in
Scott Maine1e9e932011-10-13 23:36:19 -0700656order to guarantee that your application handles the incoming NDEF message, even if other
657applications filter for the same intent action. You can create an Android application record by
658calling {@link android.nfc.NdefRecord#createApplicationRecord createApplicationRecord()}, passing it
659your application’s package name. When the other device receives the NDEF message with the
660application record and multiple applications contain activities that handle the specified intent,
661the system always delivers the message to the activity in your application (based on the matching
662application record). If the target device does not currently have your application installed, the
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -0800663system uses the Android application record to launch Google Play and take the user to the
Scott Maine1e9e932011-10-13 23:36:19 -0700664application in order to install it.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700665
666<p>If your application doesn’t use NFC APIs to perform NDEF Push messaging, then Android provides a
667default behavior: When your application is in the foreground on one device and Android Beam is
668invoked with another Android-powered device, then the other device receives an NDEF message with an
669Android application record that identifies your application. If the receiving device has the
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -0800670application installed, the system launches it; if it’s not installed, Google Play opens and takes
Scott Maine1e9e932011-10-13 23:36:19 -0700671the user to your application in order to install it.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700672
Scott Main423aca12011-10-17 16:31:11 -0700673<p>You can read more about Android Beam and other NFC features in the <a
674href="{@docRoot}guide/topics/nfc/nfc.html">NFC Basics</a> developer guide. For some example code
675using Android Beam, see the <a
Scott Maine1e9e932011-10-13 23:36:19 -0700676href="{@docRoot}resources/samples/AndroidBeamDemo/src/com/example/android/beam/Beam.html">Android
Scott Main423aca12011-10-17 16:31:11 -0700677Beam Demo</a>.</p>
678
Scott Main1d6f70c2011-10-06 22:57:25 -0700679
680
681
682
Scott Maine09743272011-10-14 11:25:46 -0700683<h3 id="WiFiDirect">Wi-Fi Direct</h3>
Scott Main1d6f70c2011-10-06 22:57:25 -0700684
Scott Maine1e9e932011-10-13 23:36:19 -0700685<p>Android now supports Wi-Fi Direct for peer-to-peer (P2P) connections between Android-powered
Scott Main1d6f70c2011-10-06 22:57:25 -0700686devices and other device types without a hotspot or Internet connection. The Android framework
687provides 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 -0700688device supports Wi-Fi Direct, then communicate over a speedy connection across distances much longer
689than a Bluetooth connection.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700690
691<p>A new package, {@link android.net.wifi.p2p}, contains all the APIs for performing peer-to-peer
692connections with Wi-Fi. The primary class you need to work with is {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700693android.net.wifi.p2p.WifiP2pManager}, which you can acquire by calling {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700694android.app.Activity#getSystemService getSystemService(WIFI_P2P_SERVICE)}. The {@link
Scott Maine1e9e932011-10-13 23:36:19 -0700695android.net.wifi.p2p.WifiP2pManager} includes APIs that allow you to:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700696<ul>
697<li>Initialize your application for P2P connections by calling {@link
698android.net.wifi.p2p.WifiP2pManager#initialize initialize()}</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700699
Scott Main1d6f70c2011-10-06 22:57:25 -0700700<li>Discover nearby devices by calling {@link android.net.wifi.p2p.WifiP2pManager#discoverPeers
701discoverPeers()}</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700702
Scott Main1d6f70c2011-10-06 22:57:25 -0700703<li>Start a P2P connection by calling {@link android.net.wifi.p2p.WifiP2pManager#connect
704connect()}</li>
705<li>And more</li>
706</ul>
707
708<p>Several other interfaces and classes are necessary as well, such as:</p>
709<ul>
710<li>The {@link android.net.wifi.p2p.WifiP2pManager.ActionListener} interface allows you to receive
711callbacks when an operation such as discovering peers or connecting to them succeeds or fails.</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700712
Scott Main1d6f70c2011-10-06 22:57:25 -0700713<li>{@link android.net.wifi.p2p.WifiP2pManager.PeerListListener} interface allows you to receive
714information about discovered peers. The callback provides a {@link
715android.net.wifi.p2p.WifiP2pDeviceList}, from which you can retrieve a {@link
716android.net.wifi.p2p.WifiP2pDevice} object for each device within range and get information such as
717the device name, address, device type, the WPS configurations the device supports, and more.</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700718
Scott Main1d6f70c2011-10-06 22:57:25 -0700719<li>The {@link android.net.wifi.p2p.WifiP2pManager.GroupInfoListener} interface allows you to
Scott Maine1e9e932011-10-13 23:36:19 -0700720receive information about a P2P group. The callback provides a {@link
721android.net.wifi.p2p.WifiP2pGroup} object, which provides group information such as the owner, the
722network name, and passphrase.</li>
723
Scott Main1d6f70c2011-10-06 22:57:25 -0700724<li>{@link android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener} interface allows you to
Scott Maine1e9e932011-10-13 23:36:19 -0700725receive information about the current connection. The callback provides a {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700726android.net.wifi.p2p.WifiP2pInfo} object, which has information such as whether a group has been
727formed and who is the group owner.</li>
728</ul>
729
730<p>In order to use the Wi-Fi P2P APIs, your app must request the following user permissions:</p>
731<ul>
732<li>{@link android.Manifest.permission#ACCESS_WIFI_STATE}</li>
733<li>{@link android.Manifest.permission#CHANGE_WIFI_STATE}</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700734<li>{@link android.Manifest.permission#INTERNET} (although your app doesn’t technically connect
Scott Mainb57769a2011-10-17 11:20:49 -0700735to the Internet, communicating to Wi-Fi Direct peers with standard java sockets requires Internet
736permission).</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700737</ul>
738
739<p>The Android system also broadcasts several different actions during certain Wi-Fi P2P events:</p>
740<ul>
741<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_CONNECTION_CHANGED_ACTION}: The P2P
Scott Maine1e9e932011-10-13 23:36:19 -0700742connection state has changed. This carries {@link
743android.net.wifi.p2p.WifiP2pManager#EXTRA_WIFI_P2P_INFO} with a {@link
744android.net.wifi.p2p.WifiP2pInfo} object and {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700745android.net.wifi.p2p.WifiP2pManager#EXTRA_NETWORK_INFO} with a {@link android.net.NetworkInfo}
746object.</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700747
Scott Main1d6f70c2011-10-06 22:57:25 -0700748<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_CHANGED_ACTION}: The P2P state has
Scott Maine1e9e932011-10-13 23:36:19 -0700749changed between enabled and disabled. It carries {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700750android.net.wifi.p2p.WifiP2pManager#EXTRA_WIFI_STATE} with either {@link
751android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_DISABLED} or {@link
752android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_ENABLED}</li>
Scott Maine1e9e932011-10-13 23:36:19 -0700753
Scott Main1d6f70c2011-10-06 22:57:25 -0700754<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_PEERS_CHANGED_ACTION}: The list of peer
Scott Maine1e9e932011-10-13 23:36:19 -0700755devices has changed.</li>
756
Scott Main1d6f70c2011-10-06 22:57:25 -0700757<li>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_THIS_DEVICE_CHANGED_ACTION}: The details for
758this device have changed.</li>
759</ul>
760
761<p>See the {@link android.net.wifi.p2p.WifiP2pManager} documentation for more information. Also
Scott Mainb57769a2011-10-17 11:20:49 -0700762look at the <a href="{@docRoot}resources/samples/WiFiDirectDemo/index.html">Wi-Fi Direct Demo</a>
Scott Maine1e9e932011-10-13 23:36:19 -0700763sample application.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700764
765
766
767
768
Scott Main423aca12011-10-17 16:31:11 -0700769<h3 id="Bluetooth">Bluetooth Health Devices</h3>
Scott Main1d6f70c2011-10-06 22:57:25 -0700770
Scott Main423aca12011-10-17 16:31:11 -0700771<p>Android now supports Bluetooth Health Profile devices, so you can create applications that use
772Bluetooth to communicate with health devices that support Bluetooth, such as heart-rate monitors,
773blood meters, thermometers, and scales.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700774
Scott Main423aca12011-10-17 16:31:11 -0700775<p>Similar to regular headset and A2DP profile devices, you must call {@link
776android.bluetooth.BluetoothAdapter#getProfileProxy getProfileProxy()} with a {@link
777android.bluetooth.BluetoothProfile.ServiceListener} and the {@link
778android.bluetooth.BluetoothProfile#HEALTH} profile type to establish a connection with the profile
779proxy object.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700780
Scott Main423aca12011-10-17 16:31:11 -0700781<p>Once you’ve acquired the Health Profile proxy (the {@link android.bluetooth.BluetoothHealth}
782object), connecting to and communicating with paired health devices involves the following new
783Bluetooth classes:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700784<ul>
Scott Main423aca12011-10-17 16:31:11 -0700785<li>{@link android.bluetooth.BluetoothHealthCallback}: You must extend this class and implement the
786callback methods to receive updates about changes in the application’s registration state and
787Bluetooth channel state.</li>
788<li>{@link android.bluetooth.BluetoothHealthAppConfiguration}: During callbacks to your {@link
789android.bluetooth.BluetoothHealthCallback}, you’ll receive an instance of this object, which
790provides configuration information about the available Bluetooth health device, which you must use
791to perform various operations such as initiate and terminate connections with the {@link
792android.bluetooth.BluetoothHealth} APIs.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700793</ul>
794
Scott Main423aca12011-10-17 16:31:11 -0700795<p>For more information about using the Bluetooth Health Profile, see the documentation for {@link
796android.bluetooth.BluetoothHealth}.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700797
798
799
800
801
802<h3 id="A11y">Accessibility</h3>
803
Scott Maine1e9e932011-10-13 23:36:19 -0700804<p>Android 4.0 improves accessibility for sight-impaired users with new explore-by-touch mode
805and extended APIs that allow you to provide more information about view content or
806develop advanced accessibility services.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700807
808
Scott Maine1e9e932011-10-13 23:36:19 -0700809<h4>Explore-by-touch mode</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700810
Scott Maine1e9e932011-10-13 23:36:19 -0700811<p>Users with vision loss can now explore the screen by touching and dragging a finger across the
812screen to hear voice descriptions of the content. Because the explore-by-touch mode works like a
813virtual cursor, it allows screen readers to identify the descriptive text the same way that screen
814readers can when the user navigates with a d-pad or trackball&mdash;by reading information provided
815by {@link android.R.attr#contentDescription android:contentDescription} and {@link
816android.view.View#setContentDescription setContentDescription()} upon a simulated "hover" event. So,
817consider this is a reminder that you should provide descriptive text for the views in your
818application, especially for {@link android.widget.ImageButton}, {@link android.widget.EditText},
819{@link android.widget.ImageView} and other widgets that might not naturally contain descriptive
820text.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700821
Scott Main1d6f70c2011-10-06 22:57:25 -0700822
Scott Maine1e9e932011-10-13 23:36:19 -0700823<h4>Accessibility for views</h4>
824
825<p>To enhance the information available to accessibility services such as screen readers, you can
826implement new callback methods for accessibility events in your custom {@link
827android.view.View} components.</p>
828
829<p>It's important to first note that the behavior of the {@link
830android.view.View#sendAccessibilityEvent sendAccessibilityEvent()} method has changed in Android
8314.0. As with previous version of Android, when the user enables accessibility services on the device
832and an input event such as a click or hover occurs, the respective view is notified with a call to
833{@link android.view.View#sendAccessibilityEvent sendAccessibilityEvent()}. Previously, the
834implementation of {@link android.view.View#sendAccessibilityEvent sendAccessibilityEvent()} would
835initialize an {@link android.view.accessibility.AccessibilityEvent} and send it to {@link
836android.view.accessibility.AccessibilityManager}. The new behavior involves some additional callback
837methods that allow the view and its parents to add more contextual information to the event:
Scott Main1d6f70c2011-10-06 22:57:25 -0700838<ol>
Scott Maine1e9e932011-10-13 23:36:19 -0700839 <li>When invoked, the {@link
840android.view.View#sendAccessibilityEvent sendAccessibilityEvent()} and {@link
841android.view.View#sendAccessibilityEventUnchecked sendAccessibilityEventUnchecked()} methods defer
842to {@link android.view.View#onInitializeAccessibilityEvent onInitializeAccessibilityEvent()}.
843 <p>Custom implementations of {@link android.view.View} might want to implement {@link
844android.view.View#onInitializeAccessibilityEvent onInitializeAccessibilityEvent()} to
845attach additional accessibility information to the {@link
846android.view.accessibility.AccessibilityEvent}, but should also call the super implementation to
847provide default information such as the standard content description, item index, and more.
848However, you should not add additional text content in this callback&mdash;that happens
849next.</p></li>
850 <li>Once initialized, if the event is one of several types that should be populated with text
851information, the view then receives a call to {@link
852android.view.View#dispatchPopulateAccessibilityEvent dispatchPopulateAccessibilityEvent()}, which
853defers to the {@link android.view.View#onPopulateAccessibilityEvent onPopulateAccessibilityEvent()}
854callback.
855 <p>Custom implementations of {@link android.view.View} should usually implement {@link
856android.view.View#onPopulateAccessibilityEvent onPopulateAccessibilityEvent()} to add additional
857text content to the {@link android.view.accessibility.AccessibilityEvent} if the {@link
858android.R.attr#contentDescription android:contentDescription} text is missing or
859insufficient. To add more text description to the
860{@link android.view.accessibility.AccessibilityEvent}, call {@link
861android.view.accessibility.AccessibilityEvent#getText()}.{@link java.util.List#add add()}.</p>
862</li>
863 <li>At this point, the {@link android.view.View} passes the event up the view hierarchy by calling
864{@link android.view.ViewGroup#requestSendAccessibilityEvent requestSendAccessibilityEvent()} on the
865parent view. Each parent view then has the chance to augment the accessibility information by
866adding an {@link android.view.accessibility.AccessibilityRecord}, until it
867ultimately reaches the root view, which sends the event to the {@link
868android.view.accessibility.AccessibilityManager} with {@link
869android.view.accessibility.AccessibilityManager#sendAccessibilityEvent
870sendAccessibilityEvent()}.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -0700871</ol>
872
Scott Maine1e9e932011-10-13 23:36:19 -0700873<p>In addition to the new methods above, which are useful when extending the {@link
874android.view.View} class, you can also intercept these event callbacks on any {@link
875android.view.View} by extending {@link
876android.view.View.AccessibilityDelegate AccessibilityDelegate} and setting it on the view with
877{@link android.view.View#setAccessibilityDelegate setAccessibilityDelegate()}.
878When you do, each accessibility method in the view defers the call to the corresponding method in
879the delegate. For example, when the view receives a call to {@link
880android.view.View#onPopulateAccessibilityEvent onPopulateAccessibilityEvent()}, it passes it to the
881same method in the {@link android.view.View.AccessibilityDelegate}. Any methods not handled by
882the delegate are given right back to the view for default behavior. This allows you to override only
883the methods necessary for any given view without extending the {@link android.view.View} class.</p>
884
885
886<p>If you want to maintain compatibility with Android versions prior to 4.0, while also supporting
887the new the accessibility APIs, you can do so with the latest version of the <em>v4 support
888library</em> (in <a href="{@docRoot}sdk/compatibility-library.html">Compatibility Package, r4</a>)
889using a set of utility classes that provide the new accessibility APIs in a backward-compatible
890design.</p>
891
892
893
Scott Main423aca12011-10-17 16:31:11 -0700894
Scott Maine1e9e932011-10-13 23:36:19 -0700895<h4>Accessibility services</h4>
896
897<p>If you're developing an accessibility service, the information about various accessibility events
898has been significantly expanded to enable more advanced accessibility feedback for users. In
899particular, events are generated based on view composition, providing better context information and
900allowing accessibility services to traverse view hierarchies to get additional view information and
901deal with special cases.</p>
902
903<p>If you're developing an accessibility service (such as a screen reader), you can access
904additional content information and traverse view hierarchies with the following procedure:</p>
905<ol>
906<li>Upon receiving an {@link android.view.accessibility.AccessibilityEvent} from an application,
907call the {@link android.view.accessibility.AccessibilityEvent#getRecord(int)
908AccessibilityEvent.getRecord()} to retrieve a specific {@link
909android.view.accessibility.AccessibilityRecord} (there may be several records attached to the
910event).</li>
911
912<li>From either {@link android.view.accessibility.AccessibilityEvent} or an individual {@link
913android.view.accessibility.AccessibilityRecord}, you can call {@link
914android.view.accessibility.AccessibilityRecord#getSource() getSource()} to retrieve a {@link
915android.view.accessibility.AccessibilityNodeInfo} object.
916 <p>An {@link android.view.accessibility.AccessibilityNodeInfo} represents a single node
917of the window content in a format that allows you to query accessibility information about that
918node. The {@link android.view.accessibility.AccessibilityNodeInfo} object returned from {@link
919android.view.accessibility.AccessibilityEvent} describes the event source, whereas the source from
920an {@link android.view.accessibility.AccessibilityRecord} describes the predecessor of the event
921source.</p></li>
922
923<li>With the {@link android.view.accessibility.AccessibilityNodeInfo}, you can query information
924about it, call {@link
925android.view.accessibility.AccessibilityNodeInfo#getParent getParent()} or {@link
926android.view.accessibility.AccessibilityNodeInfo#getChild getChild()} to traverse the view
927hierarchy, and even add child views to the node.</li>
928</ol>
929
930<p>In order for your application to publish itself to the system as an accessibility service, it
931must declare an XML configuration file that corresponds to {@link
932android.accessibilityservice.AccessibilityServiceInfo}. For more information about creating an
933accessibility service, see {@link
Scott Main1d6f70c2011-10-06 22:57:25 -0700934android.accessibilityservice.AccessibilityService} and {@link
935android.accessibilityservice.AccessibilityService#SERVICE_META_DATA
Scott Maine1e9e932011-10-13 23:36:19 -0700936SERVICE_META_DATA} for information about the XML configuration.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700937
938
Scott Maine1e9e932011-10-13 23:36:19 -0700939<h4>Other accessibility APIs</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -0700940
Scott Maine1e9e932011-10-13 23:36:19 -0700941<p>If you're interested in the device's accessibility state, the {@link
942android.view.accessibility.AccessibilityManager} has some new APIs such as:</p>
943<ul>
944 <li>{@link android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener}
945is an interface that allows you to receive a callback whenever accessibility is enabled or
946disabled.</li>
947 <li>{@link android.view.accessibility.AccessibilityManager#getEnabledAccessibilityServiceList
948 getEnabledAccessibilityServiceList()} provides information about which accessibility services
949 are currently enabled.</li>
950 <li>{@link android.view.accessibility.AccessibilityManager#isTouchExplorationEnabled()} tells
951 you whether the explore-by-touch mode is enabled.</li>
952</ul>
Scott Main1d6f70c2011-10-06 22:57:25 -0700953
954
955
Scott Main1d6f70c2011-10-06 22:57:25 -0700956
957
958
Scott Main423aca12011-10-17 16:31:11 -0700959<h3 id="SpellChecker">Spell Checker Services</h3>
Scott Main1d6f70c2011-10-06 22:57:25 -0700960
Scott Main423aca12011-10-17 16:31:11 -0700961<p>A new spell checker framework allows apps to create spell checkers in a manner similar to the
962input method framework (for IMEs). To create a new spell checker, you must implement a service that
963extends
964{@link android.service.textservice.SpellCheckerService} and extend the {@link
965android.service.textservice.SpellCheckerService.Session} class to provide spelling suggestions based
966on text provided by the interface's callback methods. In the {@link
967android.service.textservice.SpellCheckerService.Session} callback methods, you must return the
968spelling suggestions as {@link android.view.textservice.SuggestionsInfo} objects. </p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700969
Scott Main423aca12011-10-17 16:31:11 -0700970<p>Applications with a spell checker service must declare the {@link
971android.Manifest.permission#BIND_TEXT_SERVICE} permission as required by the service.
972The service must also declare an intent filter with {@code &lt;action
973android:name="android.service.textservice.SpellCheckerService" />} as the intent’s action and should
974include a {@code &lt;meta-data&gt;} element that declares configuration information for the spell
975checker. </p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700976
satok182e4ae2011-10-27 19:57:34 +0900977<p>See the sample <a href="{@docRoot}resources/samples/SpellChecker/SampleSpellCheckerService/index.html">
978Spell Checker Service</a> app and
979sample <a href="{@docRoot}resources/samples/SpellChecker/HelloSpellChecker/index.html">
980Spell Checker Client</a> app for example code.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700981
982
983
984
985<h3 id="TTS">Text-to-speech Engines</h3>
986
Scott Maine1e9e932011-10-13 23:36:19 -0700987<p>Android’s text-to-speech (TTS) APIs have been significantly extended to allow applications to
988more easily implement custom TTS engines, while applications that want to use a TTS engine have a
989couple new APIs for selecting an engine.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -0700990
991
992<h4>Using text-to-speech engines</h4>
993
994<p>In previous versions of Android, you could use the {@link android.speech.tts.TextToSpeech} class
Scott Maine1e9e932011-10-13 23:36:19 -0700995to perform text-to-speech (TTS) operations using the TTS engine provided by the system or set a
996custom engine using {@link android.speech.tts.TextToSpeech#setEngineByPackageName
997setEngineByPackageName()}. In Android 4.0, the {@link
998android.speech.tts.TextToSpeech#setEngineByPackageName setEngineByPackageName()} method has been
999deprecated and you can now specify the engine to use with a new {@link
1000android.speech.tts.TextToSpeech} constructor that accepts the package name of a TTS engine.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001001
1002<p>You can also query the available TTS engines with {@link
1003android.speech.tts.TextToSpeech#getEngines()}. This method returns a list of {@link
1004android.speech.tts.TextToSpeech.EngineInfo} objects, which include meta data such as the engine’s
1005icon, label, and package name.</p>
1006
1007
1008<h4>Building text-to-speech engines</h4>
1009
Scott Maine1e9e932011-10-13 23:36:19 -07001010<p>Previously, custom engines required that the engine be built using an undocumented native header
1011file. In Android 4.0, there is a complete set of framework APIs for building TTS engines. </p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001012
1013<p>The basic setup requires an implementation of {@link android.speech.tts.TextToSpeechService} that
1014responds to the {@link android.speech.tts.TextToSpeech.Engine#INTENT_ACTION_TTS_SERVICE} intent. The
1015primary work for a TTS engine happens during the {@link
Scott Maine1e9e932011-10-13 23:36:19 -07001016android.speech.tts.TextToSpeechService#onSynthesizeText onSynthesizeText()} callback in a service
1017that extends {@link android.speech.tts.TextToSpeechService}. The system delivers this method two
1018objects:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001019<ul>
1020<li>{@link android.speech.tts.SynthesisRequest}: This contains various data including the text to
1021synthesize, the locale, the speech rate, and voice pitch.</li>
1022<li>{@link android.speech.tts.SynthesisCallback}: This is the interface by which your TTS engine
Scott Maine1e9e932011-10-13 23:36:19 -07001023delivers the resulting speech data as streaming audio. First the engine must call {@link
Scott Main1d6f70c2011-10-06 22:57:25 -07001024android.speech.tts.SynthesisCallback#start start()} to indicate that the engine is ready to deliver
Scott Maine1e9e932011-10-13 23:36:19 -07001025the audio, then call {@link android.speech.tts.SynthesisCallback#audioAvailable audioAvailable()},
1026passing it the audio data in a byte buffer. Once your engine has passed all audio through the
1027buffer, call {@link android.speech.tts.SynthesisCallback#done()}.</li>
Scott Main1d6f70c2011-10-06 22:57:25 -07001028</ul>
1029
Scott Maine1e9e932011-10-13 23:36:19 -07001030<p>Now that the framework supports a true API for creating TTS engines, support for the native code
1031implementation has been removed. Look for a blog post about a compatibility layer
1032that you can use to convert your old TTS engines to the new framework.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001033
1034<p>For an example TTS engine using the new APIs, see the <a
Scott Mainb57769a2011-10-17 11:20:49 -07001035href="{@docRoot}resources/samples/TtsEngine/index.html">Text To Speech Engine</a> sample app.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001036
1037
1038
1039
1040
1041
Scott Main423aca12011-10-17 16:31:11 -07001042<h3 id="NetworkUsage">Network Usage</h3>
Scott Maine1e9e932011-10-13 23:36:19 -07001043
Scott Main423aca12011-10-17 16:31:11 -07001044<p>Android 4.0 gives users precise visibility of how much network data their applications are using.
1045The Settings app provides controls that allow users to manage set limits for network data usage and
1046even disable the use of background data for individual apps. In order to avoid users disabling your
Scott Mainaea8d852011-11-02 12:05:51 -07001047app’s access to data from the background, you should develop strategies to use the data
Scott Main423aca12011-10-17 16:31:11 -07001048connection efficiently and adjust your usage depending on the type of connection available.</p>
Scott Maine1e9e932011-10-13 23:36:19 -07001049
Scott Main423aca12011-10-17 16:31:11 -07001050<p>If your application performs a lot of network transactions, you should provide user settings that
1051allow users to control your app’s data habits, such as how often your app syncs data, whether to
1052perform uploads/downloads only when on Wi-Fi, whether to use data while roaming, etc. With these
1053controls available to them, users are much less likely to disable your app’s access to data when
1054they approach their limits, because they can instead precisely control how much data your app uses.
1055If you provide a preference activity with these settings, you should include in its manifest
1056declaration an intent filter for the {@link android.content.Intent#ACTION_MANAGE_NETWORK_USAGE}
1057action. For example:</p>
1058
1059<pre>
1060&lt;activity android:name="DataPreferences" android:label="@string/title_preferences">
1061 &lt;intent-filter>
1062 &lt;action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
1063 &lt;category android:name="android.intent.category.DEFAULT" />
1064 &lt;/intent-filter>
1065&lt;/activity>
1066</pre>
1067
1068<p>This intent filter indicates to the system that this is the activity that controls your
1069application’s data usage. Thus, when the user inspects how much data your app is using from the
1070Settings app, a “View application settings" button is available that launches your
1071preference activity so the user can refine how much data your app uses.</p>
1072
1073<p>Also beware that {@link android.net.ConnectivityManager#getBackgroundDataSetting()} is now
1074deprecated and always returns true&mdash;use {@link
1075android.net.ConnectivityManager#getActiveNetworkInfo()} instead. Before you attempt any network
1076transactions, you should always call {@link android.net.ConnectivityManager#getActiveNetworkInfo()}
1077to get the {@link android.net.NetworkInfo} that represents the current network and query {@link
1078android.net.NetworkInfo#isConnected()} to check whether the device has a
1079connection. You can then check other connection properties, such as whether the device is
1080roaming or connected to Wi-Fi.</p>
Scott Maine1e9e932011-10-13 23:36:19 -07001081
1082
1083
1084
Scott Main1d6f70c2011-10-06 22:57:25 -07001085
1086
1087
1088
Scott Main423aca12011-10-17 16:31:11 -07001089<h3 id="RenderScript">RenderScript</h3>
1090
1091<p>Three major features have been added to RenderScript:</p>
1092
1093<ul>
1094 <li>Off-screen rendering to a framebuffer object</li>
1095 <li>Rendering inside a view</li>
1096 <li>RS for each from the framework APIs</li>
1097</ul>
1098
1099<p>The {@link android.renderscript.Allocation} class now supports a {@link
1100android.renderscript.Allocation#USAGE_GRAPHICS_RENDER_TARGET} memory space, which allows you to
1101render things directly into the {@link android.renderscript.Allocation} and use it as a framebuffer
1102object.</p>
1103
1104<p>{@link android.renderscript.RSTextureView} provides a means to display RenderScript graphics
1105inside of a {@link android.view.View}, unlike {@link android.renderscript.RSSurfaceView}, which
1106creates a separate window. This key difference allows you to do things such as move, transform, or
1107animate an {@link android.renderscript.RSTextureView} as well as draw RenderScript graphics inside
1108a view that lies within an activity layout.</p>
1109
1110<p>The {@link android.renderscript.Script#forEach Script.forEach()} method allows you to call
1111RenderScript compute scripts from the VM level and have them automatically delegated to available
1112cores on the device. You do not use this method directly, but any compute RenderScript that you
1113write will have a {@link android.renderscript.Script#forEach forEach()} method that you can call in
1114the reflected RenderScript class. You can call the reflected {@link
1115android.renderscript.Script#forEach forEach()} method by passing in an input {@link
1116android.renderscript.Allocation} to process, an output {@link android.renderscript.Allocation} to
1117write the result to, and a {@link android.renderscript.FieldPacker} data structure in case the
1118RenderScript needs more information. Only one of the {@link android.renderscript.Allocation}s is
1119necessary and the data structure is optional.</p>
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129<h3 id="Enterprise">Enterprise</h3>
1130
1131<p>Android 4.0 expands the capabilities for enterprise application with the following features.</p>
1132
1133<h4>VPN services</h4>
1134
1135<p>The new {@link android.net.VpnService} allows applications to build their own VPN (Virtual
1136Private Network), running as a {@link android.app.Service}. A VPN service creates an interface for a
1137virtual network with its own address and routing rules and performs all reading and writing with a
1138file descriptor.</p>
1139
1140<p>To create a VPN service, use {@link android.net.VpnService.Builder}, which allows you to specify
1141the network address, DNS server, network route, and more. When complete, you can establish the
1142interface by calling {@link android.net.VpnService.Builder#establish()}, which returns a {@link
1143android.os.ParcelFileDescriptor}. </p>
1144
1145<p>Because a VPN service can intercept packets, there are security implications. As such, if you
1146implement {@link android.net.VpnService}, then your service must require the {@link
1147android.Manifest.permission#BIND_VPN_SERVICE} to ensure that only the system can bind to it (only
1148the system is granted this permission&mdash;apps cannot request it). To then use your VPN service,
1149users must manually enable it in the system settings.</p>
1150
1151
1152<h4>Device policies</h4>
1153
1154<p>Applications that manage the device restrictions can now disable the camera using {@link
1155android.app.admin.DevicePolicyManager#setCameraDisabled setCameraDisabled()} and the {@link
1156android.app.admin.DeviceAdminInfo#USES_POLICY_DISABLE_CAMERA} property (applied with a {@code
1157&lt;disable-camera /&gt;} element in the policy configuration file).</p>
1158
1159
1160<h4>Certificate management</h4>
1161
1162<p>The new {@link android.security.KeyChain} class provides APIs that allow you to import and access
1163certificates in the system key store. Certificates streamline the installation of both client
1164certificates (to validate the identity of the user) and certificate authority certificates (to
1165verify server identity). Applications such as web browsers or email clients can access the installed
1166certificates to authenticate users to servers. See the {@link android.security.KeyChain}
1167documentation for more information.</p>
1168
1169
1170
1171
1172
1173
1174
1175<h3 id="Sensors">Device Sensors</h3>
1176
1177<p>Two new sensor types have been added in Android 4.0:</p>
1178
1179<ul>
1180 <li>{@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE}: A temperature sensor that provides
1181the ambient (room) temperature in degrees Celsius.</li>
1182 <li>{@link android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY}: A humidity sensor that provides the
1183relative ambient (room) humidity as a percentage.</li>
1184</ul>
1185
1186<p>If a device has both {@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE} and {@link
1187android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY} sensors, you can use them to calculate the dew point
1188and the absolute humidity.</p>
1189
1190<p>The previous temperature sensor, {@link android.hardware.Sensor#TYPE_TEMPERATURE}, has been
1191deprecated. You should use the {@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE} sensor
1192instead.</p>
1193
1194<p>Additionally, Android’s three synthetic sensors have been greatly improved so they now have lower
1195latency and smoother output. These sensors include the gravity sensor ({@link
1196android.hardware.Sensor#TYPE_GRAVITY}), rotation vector sensor ({@link
1197android.hardware.Sensor#TYPE_ROTATION_VECTOR}), and linear acceleration sensor ({@link
1198android.hardware.Sensor#TYPE_LINEAR_ACCELERATION}). The improved sensors rely on the gyroscope
1199sensor to improve their output, so the sensors appear only on devices that have a gyroscope.</p>
1200
1201
1202
1203
Scott Main1d6f70c2011-10-06 22:57:25 -07001204
1205<h3 id="ActionBar">Action Bar</h3>
1206
1207<p>The {@link android.app.ActionBar} has been updated to support several new behaviors. Most
1208importantly, the system gracefully manages the action bar’s size and configuration when running on
Scott Maine1e9e932011-10-13 23:36:19 -07001209smaller screens in order to provide an optimal user experience on all screen sizes. For example,
1210when the screen is narrow (such as when a handset is in portrait orientation), the action bar’s
Scott Mainb57769a2011-10-17 11:20:49 -07001211navigation tabs appear in a “stacked bar," which appears directly below the main action bar. You can
1212also opt-in to a “split action bar," which places all action items in a separate bar at the bottom
Scott Maine1e9e932011-10-13 23:36:19 -07001213of the screen when the screen is narrow.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001214
1215
Scott Maine1e9e932011-10-13 23:36:19 -07001216<h4>Split action bar</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001217
Scott Maine1e9e932011-10-13 23:36:19 -07001218<p>If your action bar includes several action items, not all of them will fit into the action bar on
1219a narrow screen, so the system will place more of them into the overflow menu. However, Android 4.0
Scott Mainb57769a2011-10-17 11:20:49 -07001220allows you to enable “split action bar" so that more action items can appear on the screen in a
Scott Main1d6f70c2011-10-06 22:57:25 -07001221separate bar at the bottom of the screen. To enable split action bar, add {@link
Scott Mainb57769a2011-10-17 11:20:49 -07001222android.R.attr#uiOptions android:uiOptions} with {@code "splitActionBarWhenNarrow"} to either your
Scott Main19aad292011-10-18 16:57:32 -07001223<a href="{@docRoot}guide/topics/manifest/application-element.html">{@code &lt;application&gt;}</a>
1224tag or
1225individual <a href="{@docRoot}guide/topics/manifest/activity-element.html">{@code
1226&lt;activity&gt;}</a> tags
Scott Maine1e9e932011-10-13 23:36:19 -07001227in your manifest file. When enabled, the system will add an additional bar at the bottom of the
1228screen for all action items when the screen is narrow (no action items will appear in the primary
1229action bar).</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001230
1231<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 -07001232but don’t need the main action bar on top (you want only the tabs to appear at the top), then enable
1233the split action bar as described above and also call {@link
1234android.app.ActionBar#setDisplayShowHomeEnabled setDisplayShowHomeEnabled(false)} to disable the
1235application icon in the action bar. With nothing left in the main action bar, it
1236disappears&mdash;all that’s left are the navigation tabs at the top and the action items at the
1237bottom of the screen.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001238
1239
Scott Maine1e9e932011-10-13 23:36:19 -07001240<h4>Action bar styles</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001241
1242<p>If you want to apply custom styling to the action bar, you can use new style properties {@link
1243android.R.attr#backgroundStacked} and {@link android.R.attr#backgroundSplit} to apply a background
1244drawable or color to the stacked bar and split bar, respectively. You can also set these styles at
1245runtime with {@link android.app.ActionBar#setStackedBackgroundDrawable
1246setStackedBackgroundDrawable()} and {@link android.app.ActionBar#setSplitBackgroundDrawable
1247setSplitBackgroundDrawable()}.</p>
1248
1249
Scott Maine1e9e932011-10-13 23:36:19 -07001250<h4>Action provider</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001251
Scott Maine1e9e932011-10-13 23:36:19 -07001252<p>The new {@link android.view.ActionProvider} class allows you to create a specialized handler for
1253action items. An action provider can define an action view, a default action behavior, and a submenu
1254for each action item to which it is associated. When you want to create an action item that has
1255dynamic behaviors (such as a variable action view, default action, or submenu), extending {@link
1256android.view.ActionProvider} is a good solution in order to create a reusable component, rather than
1257handling the various action item transformations in your fragment or activity.</p>
1258
1259<p>For example, the {@link android.widget.ShareActionProvider} is an extension of {@link
Scott Mainb57769a2011-10-17 11:20:49 -07001260android.view.ActionProvider} that facilitates a “share" action from the action bar. Instead of using
Scott Maine1e9e932011-10-13 23:36:19 -07001261traditional action item that invokes the {@link android.content.Intent#ACTION_SEND} intent, you can
1262use this action provider to present an action view with a drop-down list of applications that handle
1263the {@link android.content.Intent#ACTION_SEND} intent. When the user selects an application to use
1264for the action, {@link android.widget.ShareActionProvider} remembers that selection and provides it
1265in the action view for faster access to sharing with that app.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001266
1267<p>To declare an action provider for an action item, include the {@code android:actionProviderClass}
Scott Maine1e9e932011-10-13 23:36:19 -07001268attribute in the <a href="{@docRoot}guide/topics/resources/menu-resource.html#item-element">{@code
1269&lt;item&gt;}</a> element for your activity’s options menu, with the class name of the action
1270provider as the value. For example:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001271
1272<pre>
1273&lt;item android:id="@+id/menu_share"
1274 android:title="Share"
Scott Main1d6f70c2011-10-06 22:57:25 -07001275 android:showAsAction="ifRoom"
1276 android:actionProviderClass="android.widget.ShareActionProvider" /&gt;
1277</pre>
1278
1279<p>In your activity’s {@link android.app.Activity#onCreateOptionsMenu onCreateOptionsMenu()}
Scott Maine1e9e932011-10-13 23:36:19 -07001280callback method, retrieve an instance of the action provider from the menu item and set the
1281intent:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001282
1283<pre>
1284public boolean onCreateOptionsMenu(Menu menu) {
1285 getMenuInflater().inflate(R.menu.options, menu);
1286 ShareActionProvider shareActionProvider =
1287 (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider();
1288 // Set the share intent of the share action provider.
1289 shareActionProvider.setShareIntent(createShareIntent());
1290 ...
1291 return super.onCreateOptionsMenu(menu);
1292}
1293</pre>
1294
Scott Maincd1b08e2011-12-27 16:22:27 -08001295<p>For an example using the {@link android.widget.ShareActionProvider}, see <a
1296href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/ActionBarShareActionProviderActivity.html"
1297>ActionBarShareActionProviderActivity</a> in ApiDemos.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001298
1299
Scott Maine1e9e932011-10-13 23:36:19 -07001300<h4>Collapsible action views</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001301
Scott Maine1e9e932011-10-13 23:36:19 -07001302<p>Action items that provide an action view can now toggle between their action view state and
Scott Main1d6f70c2011-10-06 22:57:25 -07001303traditional action item state. Previously only the {@link android.widget.SearchView} supported
1304collapsing when used as an action view, but now you can add an action view for any action item and
1305switch between the expanded state (action view is visible) and collapsed state (action item is
1306visible).</p>
1307
1308<p>To declare that an action item that contains an action view be collapsible, include the {@code
Scott Mainb57769a2011-10-17 11:20:49 -07001309“collapseActionView"} flag in the {@code android:showAsAction} attribute for the <a
Scott Maine1e9e932011-10-13 23:36:19 -07001310href="{@docRoot}guide/topics/resources/menu-resource.html#item-element">{@code
1311&lt;item&gt;}</a> element in the menu’s XML file.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001312
1313<p>To receive callbacks when an action view switches between expanded and collapsed, register an
1314instance of {@link android.view.MenuItem.OnActionExpandListener} with the respective {@link
1315android.view.MenuItem} by calling {@link android.view.MenuItem#setOnActionExpandListener
1316setOnActionExpandListener()}. Typically, you should do so during the {@link
1317android.app.Activity#onCreateOptionsMenu onCreateOptionsMenu()} callback.</p>
1318
1319<p>To control a collapsible action view, you can call {@link
1320android.view.MenuItem#collapseActionView()} and {@link android.view.MenuItem#expandActionView()} on
1321the respective {@link android.view.MenuItem}.</p>
1322
1323<p>When creating a custom action view, you can also implement the new {@link
1324android.view.CollapsibleActionView} interface to receive callbacks when the view is expanded and
1325collapsed.</p>
1326
1327
Scott Maine1e9e932011-10-13 23:36:19 -07001328<h4>Other APIs for action bar</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001329<ul>
Scott Maine1e9e932011-10-13 23:36:19 -07001330<li>{@link android.app.ActionBar#setHomeButtonEnabled setHomeButtonEnabled()} allows you to specify
Scott Mainb57769a2011-10-17 11:20:49 -07001331whether the icon/logo behaves as a button to navigate home or “up" (pass “true" to make it behave as
Scott Maine1e9e932011-10-13 23:36:19 -07001332a button).</li>
1333
Scott Main1d6f70c2011-10-06 22:57:25 -07001334<li>{@link android.app.ActionBar#setIcon setIcon()} and {@link android.app.ActionBar#setLogo
Scott Maine1e9e932011-10-13 23:36:19 -07001335setLogo()} allow you to define the action bar icon or logo at runtime.</li>
1336
Scott Main1d6f70c2011-10-06 22:57:25 -07001337<li>{@link android.app.Fragment#setMenuVisibility Fragment.setMenuVisibility()} allows you to enable
Scott Maine1e9e932011-10-13 23:36:19 -07001338or disable the visibility of the options menu items declared by the fragment. This is useful if the
Scott Main1d6f70c2011-10-06 22:57:25 -07001339fragment has been added to the activity, but is not visible, so the menu items should be
1340hidden.</li>
Scott Maine1e9e932011-10-13 23:36:19 -07001341
Scott Main1d6f70c2011-10-06 22:57:25 -07001342<li>{@link android.app.FragmentManager#invalidateOptionsMenu
1343FragmentManager.invalidateOptionsMenu()}
1344allows you to invalidate the activity options menu during various states of the fragment lifecycle
1345in which using the equivalent method from {@link android.app.Activity} might not be available.</li>
1346</ul>
1347
1348
1349
1350
1351
1352
1353
1354
1355<h3 id="UI">User Interface and Views</h3>
1356
1357<p>Android 4.0 introduces a variety of new views and other UI components.</p>
1358
Scott Maine1e9e932011-10-13 23:36:19 -07001359
Scott Main1d6f70c2011-10-06 22:57:25 -07001360<h4>GridLayout</h4>
1361
1362<p>{@link android.widget.GridLayout} is a new view group that places child views in a rectangular
Scott Maine1e9e932011-10-13 23:36:19 -07001363grid. Unlike {@link android.widget.TableLayout}, {@link android.widget.GridLayout} relies on a flat
Scott Main1d6f70c2011-10-06 22:57:25 -07001364hierarchy and does not make use of intermediate views such as table rows for providing structure.
1365Instead, children specify which row(s) and column(s) they should occupy (cells can span multiple
1366rows and/or columns), and by default are laid out sequentially across the grid’s rows and columns.
1367The {@link android.widget.GridLayout} orientation determines whether sequential children are by
1368default laid out horizontally or vertically. Space between children may be specified either by using
1369instances of the new {@link android.widget.Space} view or by setting the relevant margin parameters
1370on children.</p>
1371
1372<p>See <a
Scott Mainb57769a2011-10-17 11:20:49 -07001373href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/index.html">ApiDemos</a
1374>
Scott Main1d6f70c2011-10-06 22:57:25 -07001375for samples using {@link android.widget.GridLayout}.</p>
1376
1377
1378
1379<h4>TextureView</h4>
1380
1381<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 -07001382as a video or an OpenGL scene. Although similar to {@link android.view.SurfaceView}, {@link
Scott Main1d6f70c2011-10-06 22:57:25 -07001383android.view.TextureView} is unique in that it behaves like a regular view, rather than creating a
1384separate window, so you can treat it like any other {@link android.view.View} object. For example,
Scott Maine1e9e932011-10-13 23:36:19 -07001385you can apply transforms, animate it using {@link android.view.ViewPropertyAnimator}, or
Scott Main1d6f70c2011-10-06 22:57:25 -07001386adjust its opacity with {@link android.view.View#setAlpha setAlpha()}.</p>
1387
1388<p>Beware that {@link android.view.TextureView} works only within a hardware accelerated window.</p>
1389
1390<p>For more information, see the {@link android.view.TextureView} documentation.</p>
1391
1392
Scott Maine1e9e932011-10-13 23:36:19 -07001393<h4>Switch widget</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001394
1395<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 -07001396side or the other (or simply tap) to toggle an option between two states.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001397
Scott Maine1e9e932011-10-13 23:36:19 -07001398<p>You can use the {@code android:textOn} and {@code android:textOff} attributes to specify the text
1399to appear on the switch when in the on and off setting. The {@code android:text} attribute also
1400allows you to place a label alongside the switch.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001401
1402<p>For a sample using switches, see the <a
Scott Mainb57769a2011-10-17 11:20:49 -07001403href="{@docRoot}resources/samples/ApiDemos/res/layout/switches.html">switches.xml</a> layout file
Scott Main1d6f70c2011-10-06 22:57:25 -07001404and respective <a
Scott Mainb57769a2011-10-17 11:20:49 -07001405href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/Switches.html">Switches
Scott Main1d6f70c2011-10-06 22:57:25 -07001406</a> activity.</p>
1407
1408
Scott Maine1e9e932011-10-13 23:36:19 -07001409<h4>Popup menus</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001410
1411<p>Android 3.0 introduced {@link android.widget.PopupMenu} to create short contextual menus that pop
Scott Maine1e9e932011-10-13 23:36:19 -07001412up at an anchor point you specify (usually at the point of the item selected). Android 4.0 extends
1413the {@link android.widget.PopupMenu} with a couple useful features:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001414<ul>
1415<li>You can now easily inflate the contents of a popup menu from an XML <a
Scott Mainb57769a2011-10-17 11:20:49 -07001416href="{@docRoot}guide/topics/resources/menu-resource.html">menu resource</a> with {@link
Scott Main1d6f70c2011-10-06 22:57:25 -07001417android.widget.PopupMenu#inflate inflate()}, passing it the menu resource ID.</li>
1418<li>You can also now create a {@link android.widget.PopupMenu.OnDismissListener} that receives a
1419callback when the menu is dismissed.</li>
1420</ul>
1421
Scott Maine1e9e932011-10-13 23:36:19 -07001422
Scott Main1d6f70c2011-10-06 22:57:25 -07001423<h4>Preferences</h4>
1424
1425<p>A new {@link android.preference.TwoStatePreference} abstract class serves as the basis for
1426preferences that provide a two-state selection option. The new {@link
1427android.preference.SwitchPreference} is an extension of {@link
1428android.preference.TwoStatePreference} that provides a {@link android.widget.Switch} widget in the
1429preference view to allow users to toggle a setting on or off without the need to open an additional
1430preference screen or dialog. For example, the Settings application uses a {@link
1431android.preference.SwitchPreference} for the Wi-Fi and Bluetooth settings.</p>
1432
1433
Scott Main423aca12011-10-17 16:31:11 -07001434
1435<h4>System themes</h4>
1436
1437<p>The default theme for all applications that target Android 4.0 (by setting either <a
1438href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> or
1439<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> to
1440{@code “14"} or higher) is now the
1441"device default" theme: {@link android.R.style#Theme_DeviceDefault Theme.DeviceDefault}. This may be
1442the dark Holo theme or a different dark theme defined by the specific device.</p>
1443
1444<p>The {@link android.R.style#Theme_Holo Theme.Holo} family of themes are guaranteed to not change
1445from one device to another when running the same version of Android. If you explicitly
1446apply any of the {@link android.R.style#Theme_Holo Theme.Holo} themes to your activities, you can
1447rest assured that these themes will not change character on different devices within the same
1448platform version.</p>
1449
1450<p>If you wish for your app to blend in with the overall device theme (such as when different OEMs
1451provide different default themes for the system), you should explicitly apply themes from the {@link
1452android.R.style#Theme_DeviceDefault Theme.DeviceDefault} family.</p>
1453
1454
1455<h4>Options menu button</h4>
1456
1457<p>Beginning with Android 4.0, you'll notice that handsets no longer require a Menu hardware button.
1458However, there's no need for you to worry about this if your existing application provides an <a
1459href="{@docRoot}guide/topics/ui/menus.html#options-menu">options menu</a> and expects there to be a
1460Menu button. To ensure that existing apps continue to work as they expect, the system provides an
1461on-screen Menu button for apps that were designed for older versions of Android.</p>
1462
1463<p>For the best user experience, new and updated apps should instead use the {@link
1464android.app.ActionBar} to provide access to menu items and set <a
1465href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> to
1466{@code "14"} to take advantage of the latest framework default behaviors.</p>
1467
1468
1469
1470<h4>Controls for system UI visibility</h4>
1471
1472<p>Since the early days of Android, the system has managed a UI component known as the <em>status
1473bar</em>, which resides at the top of handset devices to deliver information such as the carrier
1474signal, time, notifications, and so on. Android 3.0 added the <em>system bar</em> for tablet
1475devices, which resides at the bottom of the screen to provide system navigation controls (Home,
1476Back, and so forth) and also an interface for elements traditionally provided by the status bar. In
1477Android 4.0, the system provides a new type of system UI called the <em>navigation bar</em>. You
1478might consider the navigation bar a re-tuned version of the system bar designed for
1479handsets&mdash;it provides navigation controls
1480for devices that don’t have hardware counterparts for navigating the system, but it leaves out the
1481system bar's notification UI and setting controls. As such, a device that provides the navigation
1482bar also has the status bar at the top.</p>
1483
1484<p>To this day, you can hide the status bar on handsets using the {@link
1485android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN} flag. In Android 4.0, the APIs that control
1486the system bar’s visibility have been updated to better reflect the behavior of both the system bar
1487and navigation bar:</p>
1488<ul>
1489<li>The {@link android.view.View#SYSTEM_UI_FLAG_LOW_PROFILE} flag replaces the {@code
1490STATUS_BAR_HIDDEN} flag. When set, this flag enables “low profile" mode for the system bar or
1491navigation bar. Navigation buttons dim and other elements in the system bar also hide. Enabling
1492this is useful for creating more immersive games without distraction for the system navigation
1493buttons.</li>
1494
1495<li>The {@link android.view.View#SYSTEM_UI_FLAG_VISIBLE} flag replaces the {@code
1496STATUS_BAR_VISIBLE} flag to request the system bar or navigation bar be visible.</li>
1497
1498<li>The {@link android.view.View#SYSTEM_UI_FLAG_HIDE_NAVIGATION} is a new flag that requests
1499the navigation bar hide completely. Be aware that this works only for the <em>navigation bar</em>
1500used by some handsets (it does <strong>not</strong> hide the system bar on tablets). The navigation
1501bar returns to view as soon as the system receives user input. As such, this mode is useful
1502primarily for video playback or other cases in which the whole screen is needed but user input is
1503not required.</li>
1504</ul>
1505
1506<p>You can set each of these flags for the system bar and navigation bar by calling {@link
1507android.view.View#setSystemUiVisibility setSystemUiVisibility()} on any view in your activity. The
1508window manager combines (OR-together) all flags from all views in your window and
1509apply them to the system UI as long as your window has input focus. When your window loses input
1510focus (the user navigates away from your app, or a dialog appears), your flags cease to have effect.
1511Similarly, if you remove those views from the view hierarchy their flags no longer apply.</p>
1512
1513<p>To synchronize other events in your activity with visibility changes to the system UI (for
1514example, hide the action bar or other UI controls when the system UI hides), you should register a
1515{@link android.view.View.OnSystemUiVisibilityChangeListener} to be notified when the visibility
1516of the system bar or navigation bar changes.</p>
1517
1518<p>See the <a
1519href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/OverscanActivity.html">
1520OverscanActivity</a> class for a demonstration of different system UI options.</p>
1521
1522
1523
1524
1525
1526<h3 id="Input">Input Framework</h3>
1527
1528<p>Android 4.0 adds support for cursor hover events and new stylus and mouse button events.</p>
1529
Scott Maine1e9e932011-10-13 23:36:19 -07001530<h4>Hover events</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001531
Scott Mainb57769a2011-10-17 11:20:49 -07001532<p>The {@link android.view.View} class now supports “hover" events to enable richer interactions
Scott Maine1e9e932011-10-13 23:36:19 -07001533through the use of pointer devices (such as a mouse or other devices that drive an on-screen
Scott Main1d6f70c2011-10-06 22:57:25 -07001534cursor).</p>
1535
1536<p>To receive hover events on a view, implement the {@link android.view.View.OnHoverListener} and
1537register it with {@link android.view.View#setOnHoverListener setOnHoverListener()}. When a hover
1538event occurs on the view, your listener receives a call to {@link
1539android.view.View.OnHoverListener#onHover onHover()}, providing the {@link android.view.View} that
1540received the event and a {@link android.view.MotionEvent} that describes the type of hover event
1541that occurred. The hover event can be one of the following:</p>
1542<ul>
1543<li>{@link android.view.MotionEvent#ACTION_HOVER_ENTER}</li>
1544<li>{@link android.view.MotionEvent#ACTION_HOVER_EXIT}</li>
1545<li>{@link android.view.MotionEvent#ACTION_HOVER_MOVE}</li>
1546</ul>
1547
1548<p>Your {@link android.view.View.OnHoverListener} should return true from {@link
1549android.view.View.OnHoverListener#onHover onHover()} if it handles the hover event. If your
1550listener returns false, then the hover event will be dispatched to the parent view as usual.</p>
1551
1552<p>If your application uses buttons or other widgets that change their appearance based on the
Scott Maine1e9e932011-10-13 23:36:19 -07001553current state, you can now use the {@code android:state_hovered} attribute in a <a
Scott Mainb57769a2011-10-17 11:20:49 -07001554href="{@docRoot}guide/topics/resources/drawable-resource.html#StateList">state list drawable</a> to
Scott Main1d6f70c2011-10-06 22:57:25 -07001555provide a different background drawable when a cursor hovers over the view.</p>
1556
1557<p>For a demonstration of the new hover events, see the <a
Scott Main19aad292011-10-18 16:57:32 -07001558href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/view/Hover.html">Hover</a> class in
Scott Main1d6f70c2011-10-06 22:57:25 -07001559ApiDemos.</p>
1560
1561
Scott Maine1e9e932011-10-13 23:36:19 -07001562<h4>Stylus and mouse button events</h4>
Scott Main1d6f70c2011-10-06 22:57:25 -07001563
1564<p>Android now provides APIs for receiving input from a stylus input device such as a digitizer
Scott Maine1e9e932011-10-13 23:36:19 -07001565tablet peripheral or a stylus-enabled touch screen.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001566
1567<p>Stylus input operates in a similar manner to touch or mouse input. When the stylus is in contact
1568with the digitizer, applications receive touch events just like they would when a finger is used to
1569touch the display. When the stylus is hovering above the digitizer, applications receive hover
1570events just like they would when a mouse pointer was being moved across the display when no buttons
1571are pressed.</p>
1572
1573<p>Your application can distinguish between finger, mouse, stylus and eraser input by querying the
Scott Mainb57769a2011-10-17 11:20:49 -07001574“tool type" associated with each pointer in a {@link android.view.MotionEvent} using {@link
Scott Main1d6f70c2011-10-06 22:57:25 -07001575android.view.MotionEvent#getToolType getToolType()}. The currently defined tool types are: {@link
1576android.view.MotionEvent#TOOL_TYPE_UNKNOWN}, {@link android.view.MotionEvent#TOOL_TYPE_FINGER},
1577{@link android.view.MotionEvent#TOOL_TYPE_MOUSE}, {@link android.view.MotionEvent#TOOL_TYPE_STYLUS},
1578and {@link android.view.MotionEvent#TOOL_TYPE_ERASER}. By querying the tool type, your application
1579can choose to handle stylus input in different ways from finger or mouse input.</p>
1580
1581<p>Your application can also query which mouse or stylus buttons are pressed by querying the “button
Scott Mainb57769a2011-10-17 11:20:49 -07001582state" of a {@link android.view.MotionEvent} using {@link android.view.MotionEvent#getButtonState
Scott Main1d6f70c2011-10-06 22:57:25 -07001583getButtonState()}. The currently defined button states are: {@link
Scott Maine1e9e932011-10-13 23:36:19 -07001584android.view.MotionEvent#BUTTON_PRIMARY}, {@link android.view.MotionEvent#BUTTON_SECONDARY}, {@link
1585android.view.MotionEvent#BUTTON_TERTIARY}, {@link android.view.MotionEvent#BUTTON_BACK}, and {@link
1586android.view.MotionEvent#BUTTON_FORWARD}. For convenience, the back and forward mouse buttons are
1587automatically mapped to the {@link android.view.KeyEvent#KEYCODE_BACK} and {@link
1588android.view.KeyEvent#KEYCODE_FORWARD} keys. Your application can handle these keys to support
1589mouse button based back and forward navigation.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001590
1591<p>In addition to precisely measuring the position and pressure of a contact, some stylus input
Scott Maine1e9e932011-10-13 23:36:19 -07001592devices also report the distance between the stylus tip and the digitizer, the stylus tilt angle,
1593and the stylus orientation angle. Your application can query this information using {@link
Scott Main1d6f70c2011-10-06 22:57:25 -07001594android.view.MotionEvent#getAxisValue getAxisValue()} with the axis codes {@link
1595android.view.MotionEvent#AXIS_DISTANCE}, {@link android.view.MotionEvent#AXIS_TILT}, and {@link
1596android.view.MotionEvent#AXIS_ORIENTATION}.</p>
1597
1598<p>For a demonstration of tool types, button states and the new axis codes, see the <a
Scott Main19aad292011-10-18 16:57:32 -07001599href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html">TouchPaint
Scott Main1d6f70c2011-10-06 22:57:25 -07001600</a> class in ApiDemos.</p>
1601
1602
1603
1604
1605
1606
1607<h3 id="Properties">Properties</h3>
1608
1609<p>The new {@link android.util.Property} class provides a fast, efficient, and easy way to specify a
1610property on any object that allows callers to generically set/get values on target objects. It also
1611allows the functionality of passing around field/method references and allows code to set/get values
1612of the property without knowing the details of what the fields/methods are.</p>
1613
1614<p>For example, if you want to set the value of field {@code bar} on object {@code foo}, you would
1615previously do this:</p>
1616<pre>
1617foo.bar = value;
1618</pre>
1619
1620<p>If you want to call the setter for an underlying private field {@code bar}, you would previously
1621do this:</p>
1622<pre>
1623foo.setBar(value);
1624</pre>
1625
1626<p>However, if you want to pass around the {@code foo} instance and have some other code set the
1627{@code bar} value, there is really no way to do it prior to Android 4.0.</p>
1628
1629<p>Using the {@link android.util.Property} class, you can declare a {@link android.util.Property}
1630object {@code BAR} on class {@code Foo} so that you can set the field on instance {@code foo} of
1631class {@code Foo} like this:</p>
1632<pre>
1633BAR.set(foo, value);
1634</pre>
1635
1636<p>The {@link android.view.View} class now leverages the {@link android.util.Property} class to
1637allow you to set various fields, such as transform properties that were added in Android 3.0 ({@link
1638android.view.View#ROTATION}, {@link android.view.View#ROTATION_X}, {@link
1639android.view.View#TRANSLATION_X}, etc.).</p>
1640
1641<p>The {@link android.animation.ObjectAnimator} class also uses the {@link android.util.Property}
1642class, so you can create an {@link android.animation.ObjectAnimator} with a {@link
1643android.util.Property}, which is faster, more efficient, and more type-safe than the string-based
1644approach.</p>
1645
1646
1647
1648
1649
1650
1651<h3 id="HwAccel">Hardware Acceleration</h3>
1652
1653<p>Beginning with Android 4.0, hardware acceleration for all windows is enabled by default if your
1654application has set either <a
1655href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> or
1656<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> to
Scott Mainb57769a2011-10-17 11:20:49 -07001657{@code “14"} or higher. Hardware acceleration generally results in smoother animations, smoother
Scott Main1d6f70c2011-10-06 22:57:25 -07001658scrolling, and overall better performance and response to user interaction.</p>
1659
1660<p>If necessary, you can manually disable hardware acceleration with the <a
Scott Mainb57769a2011-10-17 11:20:49 -07001661href="{@docRoot}guide/topics/manifest/activity-element.html#hwaccel">{@code hardwareAccelerated}</a>
Scott Main1d6f70c2011-10-06 22:57:25 -07001662attribute for individual <a href="{@docRoot}guide/topics/manifest/activity-element.html">{@code
1663&lt;activity&gt;}</a> elements or the <a
1664href="{@docRoot}guide/topics/manifest/application-element.html">{@code &lt;application&gt;}</a>
1665element. You can alternatively disable hardware acceleration for individual views by calling {@link
1666android.view.View#setLayerType setLayerType(LAYER_TYPE_SOFTWARE)}.</p>
1667
Scott Maine1e9e932011-10-13 23:36:19 -07001668<p>For more information about hardware acceleration, including a list of unsupported drawing
1669operations, see the <a href="{@docRoot}guide/topics/graphics/hardware-accel.html">Hardware
1670Acceleration</a> document.</p>
1671
1672
Scott Main1d6f70c2011-10-06 22:57:25 -07001673
1674<h3 id="Jni">JNI Changes</h3>
1675
Scott Maine1e9e932011-10-13 23:36:19 -07001676<p>In previous versions of Android, JNI local references weren’t indirect handles; Android used
1677direct pointers. This wasn't a problem as long as the garbage collector didn't move objects, but it
1678seemed to work because it made it possible to write buggy code. In Android 4.0, the system now uses
1679indirect references in order to detect these bugs.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001680
Scott Mainb57769a2011-10-17 11:20:49 -07001681<p>The ins and outs of JNI local references are described in “Local and Global References" in <a
Scott Maine1e9e932011-10-13 23:36:19 -07001682href="{@docRoot}guide/practices/design/jni.html">JNI Tips</a>. In Android 4.0, <a
1683href="http://android-developers.blogspot.com/2011/07/debugging-android-jni-with-checkjni.html">
1684CheckJNI</a> has been enhanced to detect these errors. Watch the <a
Scott Mainb57769a2011-10-17 11:20:49 -07001685href="http://android-developers.blogspot.com/">Android Developers Blog</a> for an upcoming post
Scott Maine1e9e932011-10-13 23:36:19 -07001686about common errors with JNI references and how you can fix them.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001687
1688<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 -07001689the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
1690targetSdkVersion}</a> or <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
Scott Mainb57769a2011-10-17 11:20:49 -07001691minSdkVersion}</a> to {@code “14"} or higher. If you’ve set these attributes to any lower value,
Scott Maine1e9e932011-10-13 23:36:19 -07001692then JNI local references behave the same as in previous versions.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001693
1694
1695
1696
1697
1698<h3 id="WebKit">WebKit</h3>
1699<ul>
1700<li>WebKit updated to version 534.30</li>
1701<li>Support for Indic fonts (Devanagari, Bengali, and Tamil, including the complex character support
1702needed for combining glyphs) in {@link android.webkit.WebView} and the built-in Browser</li>
1703<li>Support for Ethiopic, Georgian, and Armenian fonts in {@link android.webkit.WebView} and the
1704built-in Browser</li>
1705<li>Support for <a
1706href="http://google-opensource.blogspot.com/2009/05/introducing-webdriver.html">WebDriver</a> makes
1707it easier for you to test apps that use {@link android.webkit.WebView}</li>
1708</ul>
1709
1710
1711<h4>Android Browser</h4>
1712
1713<p>The Browser application adds the following features to support web applications:</p>
1714<ul>
1715<li>Updated V8 JavaScript compiler for faster performance</li>
1716<li>Plus other notable enhancements carried over from <a
Scott Mainb57769a2011-10-17 11:20:49 -07001717href="{@docRoot}sdk/android-3.0.html">Android
Scott Main1d6f70c2011-10-06 22:57:25 -070017183.0</a> are now available for handsets:
1719<ul>
1720<li>Support for fixed position elements on all pages</li>
1721<li><a href="http://dev.w3.org/2009/dap/camera/">HTML media capture</a></li>
1722<li><a href="http://dev.w3.org/geo/api/spec-source-orientation.html">Device orientation
1723events</a></li>
1724<li><a href="http://www.w3.org/TR/css3-3d-transforms/">CSS 3D transformations</a></li>
1725</ul>
1726</li>
1727</ul>
1728
1729
1730
1731<h3 id="Permissions">Permissions</h3>
1732
1733<p>The following are new permissions:</p>
1734<ul>
1735<li>{@link android.Manifest.permission#ADD_VOICEMAIL}: Allows a voicemail service to add voicemail
1736messages to the device.</li>
1737<li>{@link android.Manifest.permission#BIND_TEXT_SERVICE}: A service that implements {@link
1738android.service.textservice.SpellCheckerService} must require this permission for itself.</li>
1739<li>{@link android.Manifest.permission#BIND_VPN_SERVICE}: A service that implements {@link
1740android.net.VpnService} must require this permission for itself.</li>
1741<li>{@link android.Manifest.permission#READ_PROFILE}: Provides read access to the {@link
1742android.provider.ContactsContract.Profile} provider.</li>
1743<li>{@link android.Manifest.permission#WRITE_PROFILE}: Provides write access to the {@link
1744android.provider.ContactsContract.Profile} provider.</li>
1745</ul>
1746
1747
1748
1749<h3 id="DeviceFeatures">Device Features</h3>
1750
1751<p>The following are new device features:</p>
1752<ul>
1753<li>{@link android.content.pm.PackageManager#FEATURE_WIFI_DIRECT}: Declares that the application
1754uses
1755Wi-Fi for peer-to-peer communications.</li>
1756</ul>
1757
1758
Scott Main423aca12011-10-17 16:31:11 -07001759<div class="special" style="margin-top:3em">
1760<p>For a detailed view of all API changes in Android {@sdkPlatformVersion} (API Level
1761{@sdkPlatformApiLevel}), see the <a
1762href="{@docRoot}sdk/api_diff/{@sdkPlatformApiLevel}/changes.html">API Differences Report</a>.</p>
1763</div>
1764
Scott Main1d6f70c2011-10-06 22:57:25 -07001765
Scott Maine1e9e932011-10-13 23:36:19 -07001766<h2 id="Honeycomb">Previous APIs</h2>
Scott Main1d6f70c2011-10-06 22:57:25 -07001767
Scott Maine1e9e932011-10-13 23:36:19 -07001768<p>In addition to everything above, Android 4.0 naturally supports all APIs from previous releases.
Scott Main423aca12011-10-17 16:31:11 -07001769Because the Android 3.x platform is available only for large-screen devices, if you've
Scott Maine1e9e932011-10-13 23:36:19 -07001770been developing primarily for handsets, then you might not be aware of all the APIs added to Android
1771in these recent releases.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001772
Scott Maine1e9e932011-10-13 23:36:19 -07001773<p>Here's a look at some of the most notable APIs you might have missed that are now available
1774on handsets as well:</p>
1775
1776<dl>
1777 <dt><a href="android-3.0.html">Android 3.0</a></dt>
1778 <dd>
1779 <ul>
1780 <li>{@link android.app.Fragment}: A framework component that allows you to separate distinct
1781elements of an activity into self-contained modules that define their own UI and lifecycle. See the
1782<a href="{@docRoot}guide/topics/fundamentals/fragments.html">Fragments</a> developer guide.</li>
1783 <li>{@link android.app.ActionBar}: A replacement for the traditional title bar at the top of
1784the activity window. It includes the application logo in the left corner and provides a new
1785interface for menu items. See the
1786<a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a> developer guide.</li>
Scott Main423aca12011-10-17 16:31:11 -07001787 <li>{@link android.content.Loader}: A framework component that facilitates asynchronous
Scott Maine1e9e932011-10-13 23:36:19 -07001788loading of data in combination with UI components to dynamically load data without blocking the
1789main thread. See the
1790<a href="{@docRoot}guide/topics/fundamentals/loaders.html">Loaders</a> developer guide.</li>
1791 <li>System clipboard: Applications can copy and paste data (beyond mere text) to and from
1792the system-wide clipboard. Clipped data can be plain text, a URI, or an intent. See the
1793<a href="{@docRoot}guide/topics/clipboard/copy-paste.html">Copy and Paste</a> developer guide.</li>
1794 <li>Drag and drop: A set of APIs built into the view framework that facilitates drag and drop
1795operations. See the
1796<a href="{@docRoot}guide/topics/ui/drag-drop.html">Drag and Drop</a> developer guide.</li>
1797 <li>An all new flexible animation framework allows you to animate arbitrary properties of any
1798object (View, Drawable, Fragment, Object, or anything else) and define animation aspects such
1799as duration, interpolation, repeat and more. The new framework makes Animations in Android
1800simpler than ever. See the
Scott Main19aad292011-10-18 16:57:32 -07001801<a href="{@docRoot}guide/topics/graphics/prop-animation.html">Property Animation</a> developer
Scott Maine1e9e932011-10-13 23:36:19 -07001802guide.</li>
1803 <li>RenderScript graphics and compute engine: RenderScript offers a high performance 3D
1804graphics rendering and compute API at the native level, which you write in the C (C99 standard),
1805providing the type of performance you expect from a native environment while remaining portable
1806across various CPUs and GPUs. See the
1807<a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer
1808guide.</li>
1809 <li>Hardware accelerated 2D graphics: You can now enable the OpenGL renderer for your
1810application by setting {android:hardwareAccelerated="true"} in your manifest element's <a
1811href="{@docRoot}guide/topics/manifest/application-element.html"><code>&lt;application&gt;</code></a>
1812element or for individual <a
1813href="{@docRoot}guide/topics/manifest/activity-element.html"><code>&lt;activity&gt;</code></a>
1814elements. This results
1815in smoother animations, smoother scrolling, and overall better performance and response to user
1816interaction.
1817 <p class="note"><strong>Note:</strong> If you set your application's <a
1818href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> or <a
1819href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a> to
1820{@code "14"} or higher, hardware acceleration is enabled by default.</p></li>
1821 <li>And much, much more. See the <a href="android-3.0.html">Android 3.0 Platform</a>
1822notes for more information.</li>
1823 </ul>
1824 </dd>
1825
1826 <dt><a href="android-3.1.html">Android 3.1</a></dt>
1827 <dd>
1828 <ul>
1829 <li>USB APIs: Powerful new APIs for integrating connected peripherals with
1830Android applications. The APIs are based on a USB stack and services that are
1831built into the platform, including support for both USB host and device interactions. See the <a
1832href="{@docRoot}guide/topics/usb/index.html">USB Host and Accessory</a> developer guide.</li>
1833 <li>MTP/PTP APIs: Applications can interact directly with connected cameras and other PTP
1834devices to receive notifications when devices are attached and removed, manage files and storage on
1835those devices, and transfer files and metadata to and from them. The MTP API implements the PTP
1836(Picture Transfer Protocol) subset of the MTP (Media Transfer Protocol) specification. See the
1837{@link android.mtp} documentation.</li>
1838 <li>RTP APIs: Android exposes an API to its built-in RTP (Real-time Transport Protocol) stack,
1839which applications can use to manage on-demand or interactive data streaming. In particular, apps
1840that provide VOIP, push-to-talk, conferencing, and audio streaming can use the API to initiate
1841sessions and transmit or receive data streams over any available network. See the {@link
1842android.net.rtp} documentation.</li>
1843 <li>Support for joysticks and other generic motion inputs.</li>
1844 <li>See the <a href="android-3.1.html">Android 3.1 Platform</a>
1845notes for many more new APIs.</li>
1846 </ul>
1847 </dd>
1848
1849 <dt><a href="android-3.2.html">Android 3.2</a></dt>
1850 <dd>
1851 <ul>
1852 <li>New screens support APIs that give you more control over how your applications are
1853displayed across different screen sizes. The API extends the existing screen support model with the
1854ability to precisely target specific screen size ranges by dimensions, measured in
1855density-independent pixel units (such as 600dp or 720dp wide), rather than by their generalized
1856screen sizes (such as large or xlarge). For example, this is important in order to help you
1857distinguish between a 5" device and a 7" device, which would both traditionally be bucketed as
1858"large" screens. See the blog post, <a
1859href="http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html">
1860New Tools for Managing Screen Sizes</a>.</li>
1861 <li>New constants for <a
1862href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a> to
1863declare landscape or portrait screen orientation requirements.</li>
1864 <li>The device "screen size" configuration now changes during a screen orientation
1865change. If your app targets API level 13 or higher, you must handle the {@code "screenSize"}
1866configuration change if you also want to handle the {@code "orientation"} configuration change. See
1867<a href="{@docRoot}guide/topics/manifest/activity-element.html#config">{@code
1868android:configChanges}</a> for more information.</li>
1869 <li>See the <a href="android-3.2.html">Android 3.2 Platform</a>
1870notes for other new APIs.</li>
1871 </ul>
1872 </dd>
1873
1874</dl>
Scott Main1d6f70c2011-10-06 22:57:25 -07001875
1876
1877
1878
Scott Main1d6f70c2011-10-06 22:57:25 -07001879<h2 id="api-level">API Level</h2>
1880
Scott Maine1e9e932011-10-13 23:36:19 -07001881<p>The Android {@sdkPlatformVersion} API is assigned an integer
1882identifier&mdash;<strong>{@sdkPlatformApiLevel}</strong>&mdash;that is stored in the system itself.
1883This identifier, called the "API level", allows the system to correctly determine whether an
1884application is compatible with the system, prior to installing the application. </p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001885
1886<p>To use APIs introduced in Android {@sdkPlatformVersion} in your application, you need compile the
Scott Maine1e9e932011-10-13 23:36:19 -07001887application against an Android platform that supports API level {@sdkPlatformApiLevel} or
1888higher. Depending on your needs, you might also need to add an
Scott Main1d6f70c2011-10-06 22:57:25 -07001889<code>android:minSdkVersion="{@sdkPlatformApiLevel}"</code> attribute to the
Scott Maine1e9e932011-10-13 23:36:19 -07001890<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code &lt;uses-sdk&gt;}</a>
1891element.</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001892
Scott Maine1e9e932011-10-13 23:36:19 -07001893<p>For more information, see the <a href="{@docRoot}guide/appendix/api-levels.html">API Levels</a>
1894document. </p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001895
1896
1897<h2 id="apps">Built-in Applications</h2>
1898
1899<p>The system image included in the downloadable platform provides these
1900built-in applications:</p>
1901
1902<table style="border:0;padding-bottom:0;margin-bottom:0;">
1903<tr>
1904<td style="border:0;padding-bottom:0;margin-bottom:0;">
1905<ul>
1906<li>API Demos</li>
1907<li>Browser</li>
1908<li>Calculator</li>
Scott Maine1e9e932011-10-13 23:36:19 -07001909<li>Calendar</li>
Scott Main1d6f70c2011-10-06 22:57:25 -07001910<li>Camera</li>
1911<li>Clock</li>
1912<li>Custom Locale</li>
1913<li>Dev Tools</li>
1914<li>Downloads</li>
1915<li>Email</li>
1916<li>Gallery</li>
1917</ul>
1918</td>
1919<td style="border:0;padding-bottom:0;margin-bottom:0;padding-left:5em;">
1920<ul>
1921<li>Gestures Builder</li>
1922<li>Messaging</li>
1923<li>Music</li>
1924<li>People</li>
1925<li>Phone</li>
1926<li>Search</li>
1927<li>Settings</li>
Scott Maine1e9e932011-10-13 23:36:19 -07001928<li>Speech Recorder</li>
Scott Main1d6f70c2011-10-06 22:57:25 -07001929<li>Widget Preview</li>
1930</ul>
1931</td>
1932</tr>
1933</table>
1934
1935
1936<h2 id="locs" style="margin-top:.75em;">Locales</h2>
1937
Scott Maine1e9e932011-10-13 23:36:19 -07001938<p>The system image included in the downloadable SDK platform provides a variety of built-in
1939locales. In some cases, region-specific strings are available for the locales. In other cases, a
1940default version of the language is used. The languages that are available in the Android 3.0 system
1941image are listed below (with <em>language</em>_<em>country/region</em> locale descriptor).</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07001942
1943<table style="border:0;padding-bottom:0;margin-bottom:0;">
1944<tr>
1945<td style="border:0;padding-bottom:0;margin-bottom:0;">
1946<ul>
1947<li>Arabic, Egypt (ar_EG)</li>
1948<li>Arabic, Israel (ar_IL)</li>
1949<li>Bulgarian, Bulgaria (bg_BG)</li>
1950<li>Catalan, Spain (ca_ES)</li>
1951<li>Czech, Czech Republic (cs_CZ)</li>
1952<li>Danish, Denmark(da_DK)</li>
1953<li>German, Austria (de_AT)</li>
1954<li>German, Switzerland (de_CH)</li>
1955<li>German, Germany (de_DE)</li>
1956<li>German, Liechtenstein (de_LI)</li>
1957<li>Greek, Greece (el_GR)</li>
1958<li>English, Australia (en_AU)</li>
1959<li>English, Canada (en_CA)</li>
1960<li>English, Britain (en_GB)</li>
1961<li>English, Ireland (en_IE)</li>
1962<li>English, India (en_IN)</li>
1963<li>English, New Zealand (en_NZ)</li>
1964<li>English, Singapore(en_SG)</li>
1965<li>English, US (en_US)</li>
Scott Mainb16965c2012-01-30 23:33:01 -08001966<li>English, South Africa (en_ZA)</li>
Scott Main1d6f70c2011-10-06 22:57:25 -07001967<li>Spanish (es_ES)</li>
1968<li>Spanish, US (es_US)</li>
1969<li>Finnish, Finland (fi_FI)</li>
1970<li>French, Belgium (fr_BE)</li>
1971<li>French, Canada (fr_CA)</li>
1972<li>French, Switzerland (fr_CH)</li>
1973<li>French, France (fr_FR)</li>
1974<li>Hebrew, Israel (he_IL)</li>
1975<li>Hindi, India (hi_IN)</li>
1976</ul>
1977</td>
1978<td style="border:0;padding-bottom:0;margin-bottom:0;padding-left:5em;">
1979<li>Croatian, Croatia (hr_HR)</li>
1980<li>Hungarian, Hungary (hu_HU)</li>
1981<li>Indonesian, Indonesia (id_ID)</li>
1982<li>Italian, Switzerland (it_CH)</li>
1983<li>Italian, Italy (it_IT)</li>
1984<li>Japanese (ja_JP)</li>
1985<li>Korean (ko_KR)</li>
1986<li>Lithuanian, Lithuania (lt_LT)</li>
1987<li>Latvian, Latvia (lv_LV)</li>
1988<li>Norwegian bokmål, Norway (nb_NO)</li>
1989<li>Dutch, Belgium (nl_BE)</li>
1990<li>Dutch, Netherlands (nl_NL)</li>
1991<li>Polish (pl_PL)</li>
1992<li>Portuguese, Brazil (pt_BR)</li>
1993<li>Portuguese, Portugal (pt_PT)</li>
1994<li>Romanian, Romania (ro_RO)</li>
1995<li>Russian (ru_RU)</li></li>
1996<li>Slovak, Slovakia (sk_SK)</li>
1997<li>Slovenian, Slovenia (sl_SI)</li>
1998<li>Serbian (sr_RS)</li>
1999<li>Swedish, Sweden (sv_SE)</li>
2000<li>Thai, Thailand (th_TH)</li>
2001<li>Tagalog, Philippines (tl_PH)</li>
2002<li>Turkish, Turkey (tr_TR)</li>
2003<li>Ukrainian, Ukraine (uk_UA)</li>
2004<li>Vietnamese, Vietnam (vi_VN)</li>
2005<li>Chinese, PRC (zh_CN)</li>
2006<li>Chinese, Taiwan (zh_TW)</li>
2007</td>
2008</tr>
2009</table>
2010
2011<p class="note"><strong>Note:</strong> The Android platform may support more
2012locales than are included in the SDK system image. All of the supported locales
2013are available in the <a href="http://source.android.com/">Android Open Source
2014Project</a>.</p>
2015
2016<h2 id="skins">Emulator Skins</h2>
2017
Scott Maine1e9e932011-10-13 23:36:19 -07002018<p>The downloadable platform includes the following emulator skins:</p>
Scott Main1d6f70c2011-10-06 22:57:25 -07002019
2020<ul>
2021 <li>
Scott Maine1e9e932011-10-13 23:36:19 -07002022 QVGA (240x320, low density, small screen)
2023 </li>
2024 <li>
2025 WQVGA400 (240x400, low density, normal screen)
2026 </li>
2027 <li>
2028 WQVGA432 (240x432, low density, normal screen)
2029 </li>
2030 <li>
2031 HVGA (320x480, medium density, normal screen)
2032 </li>
2033 <li>
2034 WVGA800 (480x800, high density, normal screen)
2035 </li>
2036 <li>
2037 WVGA854 (480x854 high density, normal screen)
2038 </li>
2039 <li>
2040 WXGA720 (1280x720, extra-high density, normal screen) <span class="new">new</span>
2041 </li>
2042 <li>
2043 WSVGA (1024x600, medium density, large screen) <span class="new">new</span>
2044 </li>
2045 <li>
2046 WXGA (1280x800, medium density, xlarge screen)
Scott Main1d6f70c2011-10-06 22:57:25 -07002047 </li>
2048</ul>
2049
Scott Maine1e9e932011-10-13 23:36:19 -07002050<p>To test your application on an emulator that represents the latest Android device, you can create
2051an AVD with the new WXGA720 skin (it's an xhdpi, normal screen device). Note that the emulator
2052currently doesn't support the new on-screen navigation bar for devices without hardware navigation
2053buttons, so when using this skin, you must use keyboard keys <em>Home</em> for the Home button,
2054<em>ESC</em> for the Back button, and <em>F2</em> or <em>Page-up</em> for the Menu button.</p>
2055
2056<p>However, due to performance issues in the emulator when running high-resolution screens such as
2057the one for the WXGA720 skin, we recommend that you primarily use the traditional WVGA800 skin
2058(hdpi, normal screen) to test your application.</p>
2059