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