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