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