1 page.title=Android 4.0.3 APIs 2 excludeFromSuggestions=true 3 sdk.platform.version=4.0.3 4 sdk.platform.apiLevel=15 5 @jd:body 6 7 <div id="qv-wrapper"> 8 <div id="qv"> 9 10 <h2>In this document</h2> 11 <ol> 12 <li><a href="#api">API Overview</a></li> 13 <li><a href="#Honeycomb">Previous APIs</a></li> 14 <li><a href="#api-level">API Level</a></li> 15 </ol> 16 17 <h2>Reference</h2> 18 <ol> 19 <li><a 20 href="{@docRoot}sdk/api_diff/15/changes.html">API 21 Differences Report »</a> </li> 22 </ol> 23 24 </div> 25 </div> 26 27 <p><em>API Level:</em> <strong>{@sdkPlatformApiLevel}</strong></p> 28 29 <p>Android {@sdkPlatformVersion} ({@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1}) 30 is an incremental release of the Android 4.x 31 (Ice Cream Sandwich) platform family. This release includes new features for 32 users and developers, API changes, and various bug fixes.</p> 33 34 <p>For developers, the Android {@sdkPlatformVersion} platform is available as a 35 downloadable component for the Android SDK. The downloadable platform includes 36 an Android library and system image, as well as a set of emulator skins and 37 more. To get started developing or testing against Android {@sdkPlatformVersion}, 38 use the Android SDK Manager to download the platform into your SDK.</p> 39 40 41 <h2 id="api">API Overview</h2> 42 43 <p>The sections below provide a technical overview of new APIs in Android 4.0.3.</p> 44 45 <div class="toggle-content closed"> 46 47 <p><a href="#" onclick="return toggleContent(this)"> 48 <img src="{@docRoot}assets/images/styles/disclosure_down.png" 49 class="toggle-content-img" alt="" /><strong>Table of Contents</strong> 50 </a></p> 51 52 <div class="toggle-content-toggleme" style="padding-left:2em;"> 53 <ol class="toc" style="margin-left:-1em"> 54 <li><a href="#contacts">Social stream API in Contacts Provider</a></li> 55 <li><a href="#calendar">Calendar Provider</a></li> 56 <li><a href="#widgets">Home screen widgets</a></li> 57 <li><a href="#textservices">Spell-checking</a></li> 58 <li><a href="#bluetooth">Bluetooth</a></li> 59 <li><a href="#ui">UI toolkit</a></li> 60 <li><a href="#accessibility">Accessibility</a></li> 61 <li><a href="#tts">Text-to-speech</a></li> 62 <li><a href="#database">Database</a></li> 63 <li><a href="#intents">Intents</a></li> 64 <li><a href="#camera">Camera</a></li> 65 <li><a href="#permissions">Permissions</a></li> 66 </ol> 67 </div> 68 </div> 69 70 71 72 73 74 <h3 id="contacts">Social stream API in Contacts Provider</h3> 75 76 <p>Applications that use social stream data such as status updates and check-ins 77 can now sync that data with each of the users contacts, providing items in a 78 stream along with photos for each.</p> 79 80 <p>The database table that contains an individual contacts social stream is 81 defined by android.provider.ContactsContract.StreamItems, the Uri for 82 which is nested within the {@link android.provider.ContactsContract.RawContacts} 83 directory to which the stream items belong. Each social stream table includes 84 several columns for metadata about each stream item, such as an icon 85 representing the source (an avatar), a label for the item, the primary text 86 content, comments about the item (such as responses from other people), and 87 more. Photos associated with a stream are stored in another table, defined by 88 android.provider.ContactsContract.StreamItemPhotos, which is available 89 as a sub-directory of the android.provider.ContactsContract.StreamItems 90 Uri.</p> 91 92 <p>See android.provider.ContactsContract.StreamItems and 93 android.provider.ContactsContract.StreamItemPhotos for more information.</p> 94 95 <p>To read or write social stream items for a contact, an application must 96 request permission from the user by declaring <code><uses-permission 97 android:name="android.permission.READ_SOCIAL_STREAM"></code> and/or <code><uses-permission 98 android:name="android.permission.WRITE_SOCIAL_STREAM"></code> in their manifest files.</p> 99 100 <h3 id="calendar">Calendar Provider</h4> 101 <ul> 102 <li>Adds the class {@link android.provider.CalendarContract.Colors} to represent 103 a color table in the <a href="{@docRoot}guide/topics/providers/calendar-provider.html">Calendar 104 Provider</a>. The class provides fields for accessing 105 colors available for a given account. Colors are referenced by 106 {@link android.provider.CalendarContract.ColorsColumns#COLOR_KEY COLOR_KEY} 107 which must be unique for a given account name/type. These values can only be 108 updated by the sync adapter.</li> 109 <li>Adds {@link android.provider.CalendarContract.CalendarColumns#ALLOWED_AVAILABILITY ALLOWED_AVAILABILITY} 110 and 111 {@link android.provider.CalendarContract.CalendarColumns#ALLOWED_ATTENDEE_TYPES ALLOWED_ATTENDEE_TYPES} 112 for exchange/sync support.</li> 113 <li>Adds {@link android.provider.CalendarContract.AttendeesColumns#TYPE_RESOURCE} 114 (such as conference rooms) for attendees and 115 {@link android.provider.CalendarContract.EventsColumns#AVAILABILITY_TENTATIVE}, 116 as well as {@link android.provider.CalendarContract.EventsColumns#EVENT_COLOR_KEY} 117 for events.</li> 118 </ul> 119 120 <h3 id="widgets">Home screen widgets</h3> 121 122 <p>Starting from Android 4.0, home screen widgets should no longer include their 123 own padding. Instead, the system now automatically adds padding for each widget, 124 based the characteristics of the current screen. This leads to a more uniform, 125 consistent presentation of widgets in a grid. To assist applications that host 126 home screen widgets, the platform provides a new method 127 {@link android.appwidget.AppWidgetHostView#getDefaultPaddingForWidget(android.content.Context, android.content.ComponentName, android.graphics.Rect) 128 getDefaultPaddingForWidget()}. Applications can call this method to get the 129 system-defined padding and account for it when computing the number of cells to 130 allocate to the widget.</p> 131 132 <h3 id="textservices">Spell-checking</h3> 133 134 <ul> 135 <li>For apps that accessing spell-checker services, a new {@link 136 android.view.textservice.SpellCheckerSession#cancel() cancel()} method cancels 137 any pending and running spell-checker tasks in a session.</li> 138 139 <li>For spell-checker services, a new suggestions flag, 140 {@link android.view.textservice.SuggestionsInfo#RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS}, 141 lets the services distinguish higher-confidence suggestions from 142 lower-confidence ones. For example, a spell-checker could set the flag if an 143 input word is not in the user dictionary but has likely suggestions, or not set 144 the flag if an input word is not in the dictionary and has suggestions that are 145 likely to be less useful. 146 147 <p>Apps connected to the spell-checker can use the {@link 148 android.view.textservice.SuggestionsInfo#RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS} 149 flag in combination with other suggestion attributes, as well as the {@link 150 android.view.textservice.SuggestionsInfo#getSuggestionsAttributes()} and {@link 151 android.view.textservice.SuggestionsInfo#getSuggestionsCount()} methods, to 152 determine whether to mark input words as typos and offer suggestions.</p></li> 153 154 <li>A new {@link android.text.style.SuggestionSpan#FLAG_AUTO_CORRECTION} style 155 for text spans indicates that auto correction is about to be applied to a 156 word/text that the user is typing/composing. This type of suggestion is rendered 157 differently, to indicate the auto correction is happening.</li> 158 </ul> 159 160 <h3 id="bluetooth">Bluetooth</h3> 161 <p>New public methods {@link 162 android.bluetooth.BluetoothDevice#fetchUuidsWithSdp()} and {@link 163 android.bluetooth.BluetoothDevice#getUuids()} let apps determine the features 164 (UUIDs) supported by a remote device. In the case of {@link 165 android.bluetooth.BluetoothDevice#fetchUuidsWithSdp()}, the system performs a 166 service discovery on the remote device to get the UUIDs supported, then 167 broadcasts the result in an {@link 168 android.bluetooth.BluetoothDevice#ACTION_UUID} intent.</p> 169 170 <h3 id="ui">UI toolkit</h3> 171 172 <p>New methods {@link android.app.Fragment#setUserVisibleHint(boolean) setUserVisibleHint()} and 173 {@link android.app.Fragment#getUserVisibleHint() getUserVisibleHint()} allow a 174 fragment to set a hint of whether or not it is currently user-visible. The 175 system defers the start of fragments that are not user-visible until the loaders 176 for visible fragments have run. The visibility hint is "true" by default.</li> 177 </p> 178 179 <h3 id="graphics">Graphics</h3> 180 181 <ul> 182 <li>New method {@link android.graphics.SurfaceTexture#setDefaultBufferSize(int 183 width, int height)} in {@link android.graphics.SurfaceTexture} sets the default size of the image 184 buffers. This method may be used to set the image size when producing images 185 with {@link android.graphics.Canvas} (via {@link 186 android.view.Surface#lockCanvas}), or OpenGL ES (via an EGLSurface).</li> 187 <li>Adds definitions for the enums of the GL_OES_EGL_image_external OpenGL ES extension — 188 {@link android.opengl.GLES11Ext#GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES}, 189 {@link android.opengl.GLES11Ext#GL_SAMPLER_EXTERNAL_OES}, 190 {@link android.opengl.GLES11Ext#GL_TEXTURE_BINDING_EXTERNAL_OES}, and 191 {@link android.opengl.GLES11Ext#GL_TEXTURE_EXTERNAL_OES}.</li> 192 </ul> 193 194 <h3 id="accessibility">Accessibility</h3> 195 196 <ul> 197 <li>Clients of {@link android.widget.RemoteViews} can now use the method {@link 198 android.widget.RemoteViews#setContentDescription(int, java.lang.CharSequence) 199 setContentDescription()} to set and get the content description of any View in 200 the inflated layout.</li> 201 202 <li>The methods {@link android.view.accessibility.AccessibilityRecord#getMaxScrollX()}, 203 {@link android.view.accessibility.AccessibilityRecord#getMaxScrollY()}, 204 {@link android.view.accessibility.AccessibilityRecord#setMaxScrollX(int) setMaxScrollX()}, and 205 {@link android.view.accessibility.AccessibilityRecord#setMaxScrollY(int) setMaxScrollY()} 206 allow apps to get and set the maximum scroll offset for an 207 {@link android.view.accessibility.AccessibilityRecord} object.</li> 208 209 <li>When touch-exploration mode is enabled, a new secure setting 210 {@link android.provider.Settings.Secure#ACCESSIBILITY_SPEAK_PASSWORD} 211 indicates whether the user requests the IME to speak text entered in password fields, even when 212 a headset is not in use. By default, no password text is spoken unless a headset 213 is in use.</li> 214 </ul> 215 216 <h3 id="tts">Text-to-speech</h3> 217 218 <ul> 219 <li>Adds the new method {@link 220 android.speech.tts.TextToSpeech#getFeatures(java.util.Locale) 221 getFeatures()}for querying and enabling network TTS support. 222 <li>Adds a new listener class, {@link 223 android.speech.tts.UtteranceProgressListener}, that engines can register to 224 receive notification of speech-synthesis errors.</li> 225 </ul> 226 227 <h3 id="database">Database</h3> 228 229 <ul> 230 <li>A new {@link android.database.CrossProcessCursorWrapper} class lets content 231 providers return results for a cross-process query more efficiently. The new 232 class is a useful building block for wrapping cursors that will be sent to 233 processes remotely. It can also transform normal {@link android.database.Cursor} 234 objects into {@link android.database.CrossProcessCursor} objects 235 transparently. 236 237 <p>The {@link android.database.CrossProcessCursorWrapper} class fixes common 238 performance issues and bugs that applications have encountered when 239 implementing content providers.</p></li> 240 241 <li>The {@link android.database.CursorWindow#CursorWindow(java.lang.String)} 242 constructor now takes a name string as input. The system no longer distinguishes 243 between local and remote cursor windows, so {@link 244 android.database.CursorWindow#CursorWindow(boolean)} is now deprecated.</li> 245 </ul> 246 247 <h3 id="intents">Intents</h3> 248 249 <p>Adds new categories for targeting common types of applications on the 250 device, such as {@link android.content.Intent#CATEGORY_APP_BROWSER}, {@link 251 android.content.Intent#CATEGORY_APP_CALENDAR}, {@link 252 android.content.Intent#CATEGORY_APP_MAPS}, and more.</li> 253 254 <h3 id="camera">Camera</h3> 255 256 <ul> 257 <li>{@link android.media.MediaMetadataRetriever} adds the new constant 258 {@link android.media.MediaMetadataRetriever#METADATA_KEY_LOCATION} to let apps 259 access retrieve location information for an image or video. </li> 260 261 <li>{@link android.media.CamcorderProfile} adds the QVGA (320x240) resolution 262 profiles. Quality level is represented by the 263 {@link android.media.CamcorderProfile#QUALITY_QVGA}.and 264 {@link android.media.CamcorderProfile#QUALITY_TIME_LAPSE_QVGA} constants.</li> 265 266 <li>New methods {@link android.hardware.Camera.Parameters#setVideoStabilization(boolean) setVideoStabilization()}, 267 {@link android.hardware.Camera.Parameters#getVideoStabilization() getVideoStabilization()}, and {@link android.hardware.Camera.Parameters#isVideoStabilizationSupported() isVideoStabilizationSupported()} 268 let you check and manage video stabilization for a {@link android.hardware.Camera}.</li> 269 </ul> 270 271 <h3 id="Permissions">Permissions</h3> 272 273 <p>The following are new permissions:</p> 274 <ul> 275 <li>android.Manifest.permission#READ_SOCIAL_STREAM and 276 android.Manifest.permission#WRITE_SOCIAL_STREAM: Allow a sync 277 adapter to read and write social stream data to a contact in the shared 278 Contacts Provider.</li> 279 </ul> 280 281 282 <div class="special" style="margin-top:2em"> 283 <p>For a detailed view of all API changes in Android {@sdkPlatformVersion} (API Level 284 {@sdkPlatformApiLevel}), see the <a 285 href="{@docRoot}sdk/api_diff/{@sdkPlatformApiLevel}/changes.html">API Differences Report</a>.</p> 286 </div> 287 288 289 <h2 id="api-level">API Level</h2> 290 291 <p>The Android {@sdkPlatformVersion} API is assigned an integer 292 identifier—<strong>{@sdkPlatformApiLevel}</strong>—that is stored in the system itself. 293 This identifier, called the "API level", allows the system to correctly determine whether an 294 application is compatible with the system, prior to installing the application. </p> 295 296 <p>To use APIs introduced in Android {@sdkPlatformVersion} in your application, you need compile the 297 application against an Android platform that supports API level {@sdkPlatformApiLevel} or 298 higher. Depending on your needs, you might also need to add an 299 <code>android:minSdkVersion="{@sdkPlatformApiLevel}"</code> attribute to the 300 <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code <uses-sdk>}</a> 301 element.</p> 302 303 <p>For more information, see the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">API Levels</a> 304 document. </p> 305 306