Robert Ly | c8590ff | 2014-06-20 09:33:39 -0700 | [diff] [blame] | 1 | page.title=API Overview |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 2 | excludeFromSuggestions=true |
| 3 | sdk.platform.apiLevel=20 |
| 4 | @jd:body |
| 5 | |
| 6 | |
| 7 | <div id="qv-wrapper"> |
| 8 | <div id="qv"> |
| 9 | |
| 10 | <h2>In this document |
| 11 | <a href="#" onclick="hideNestedItems('#toc44',this);return false;" class="header-toggle"> |
| 12 | <span class="more">show more</span> |
| 13 | <span class="less" style="display:none">show less</span></a></h2> |
| 14 | |
| 15 | <ol id="toc44" class="hide-nested"> |
| 16 | <li><a href="#Behaviors">Important Behavior Changes</a> |
| 17 | <ol> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 18 | <li><a href="#ART">New Android Runtime (ART)</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 19 | <li><a href="#BehaviorNotifications">If your app implements notifications...</a></li> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 20 | <li><a href="#BehaviorMediaControl">If your app uses RemoteControlClient...</a></li> |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 21 | <li><a href="#BehaviorGetRecentTasks">If your app uses ActivityManager.getRecentTasks()...</a></li> |
Quddus Chong | 20dad64d | 2014-07-18 13:21:48 -0700 | [diff] [blame] | 22 | <li><a href="#64BitSupport">If you are using the Android Native Development Kit (NDK)...</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 23 | </ol> |
| 24 | </li> |
| 25 | <li><a href="#UI">User Interface</a> |
| 26 | <ol> |
| 27 | <li><a href="#MaterialDesign">Material design support</a></li> |
| 28 | <li><a href="#LockscreenNotifications">Lockscreen notifications</a></li> |
| 29 | <li><a href="#NotificationsMetadata">Notifications metadata</a></li> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 30 | <li><a href="#Recents">Concurrent documents and activities in the Recents screen</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 31 | <li><a href="#WebView">WebView updates</a></li> |
| 32 | </ol> |
| 33 | </li> |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 34 | <li><a href="#Graphics">Graphics</a> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 35 | <ol> |
| 36 | <li><a href="#OpenGLES-3-1">Support for OpenGL ES 3.1</a></li> |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 37 | <li><a href="#AndroidExtensionPack">Android Extension Pack</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 38 | </ol> |
| 39 | </li> |
| 40 | <li><a href="#Multimedia">Multimedia</a> |
| 41 | <ol> |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 42 | <li><a href="#Camera-v2">Camera API for advanced camera capabilities</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 43 | <li><a href="#AudioPlayback">Audio playback</a></li> |
| 44 | <li><a href="#MediaPlaybackControl">Media playback control</a></li> |
| 45 | </ol> |
| 46 | </li> |
| 47 | <li><a href="#Storage">Storage</a> |
| 48 | <ol> |
| 49 | <li><a href="#DirectorySelection">Directory selection</a></li> |
| 50 | </ol> |
| 51 | </li> |
| 52 | <li><a href="#Wireless">Wireless and Connectivity</a> |
| 53 | <ol> |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 54 | <li><a href="#Multinetwork">Multiple network connections</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 55 | <li><a href="#BluetoothBroadcasting">Bluetooth broadcasting</a></li> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 56 | <li><a href="#NFCEnhancements">NFC enhancements</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 57 | </ol> |
| 58 | </li> |
| 59 | <li><a href="#Power">Power Efficiency</a> |
| 60 | <ol> |
| 61 | <li><a href="#JobScheduler">Scheduling Jobs</a></li> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 62 | <li><a href="#PowerMeasurementTools">Developer tools for power measurement</a> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 63 | </ol> |
| 64 | </li> |
| 65 | <li><a href="#Enterprise">Enterprise</a> |
| 66 | <ol> |
| 67 | <li><a href="#ManagedProvisioning">Managed provisioning</a></li> |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 68 | <li><a href="#TaskLocking">Task locking</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 69 | </ol> |
| 70 | </li> |
| 71 | <li><a href="#Printing">Printing Framework</a> |
| 72 | <ol> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 73 | <li><a href="#PDFRender">Render PDF as bitmap</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 74 | </ol> |
| 75 | </li> |
| 76 | <li><a href="#TestingA11y">Testing & Accessibility</a> |
| 77 | <ol> |
| 78 | <li><a href="#TestingA11yImprovements">Testing and accessibility improvements</a></li> |
| 79 | </ol> |
| 80 | </li> |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 81 | <li><a href="#IME">IME</a> |
| 82 | <ol> |
| 83 | <li><a href="#Switching">Easier switching between input languages</a></li> |
| 84 | </ol> |
| 85 | </li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 86 | <li><a href="#Manifest">Manifest Declarations</a> |
| 87 | <ol> |
| 88 | <li><a href="#ManifestFeatures">Declarable required features</a></li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 89 | </ol> |
| 90 | </li> |
| 91 | </ol> |
| 92 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 93 | </div> |
| 94 | </div> |
| 95 | |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 96 | <p>The L Developer Preview gives you an advance look at the upcoming release |
| 97 | for the Android platform, which offers new features for users and app |
| 98 | developers. This document provides an introduction to the most notable APIs.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 99 | |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 100 | <p>The L Developer Preview is intended for <strong>developer early |
| 101 | adopters</strong> and <strong>testers</strong>. If you are interested in |
| 102 | influencing the direction of the Android framework, |
| 103 | <a href="{@docRoot}preview/setup-sdk.html">give the L Developer Preview a |
| 104 | try</a> and send us your feedback!</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 105 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 106 | <p class="caution"><strong>Caution:</strong> Do not not publish apps |
| 107 | that use the L Developer Preview to the Google Play store.</p> |
| 108 | |
| 109 | <p class="note"><strong>Note:</strong> This document often refers to classes and |
| 110 | methods that do not yet have reference material available on <a |
| 111 | href="{@docRoot}">developer.android.com</a>. These API elements are |
| 112 | formatted in {@code code style} in this document (without hyperlinks). For the |
| 113 | preliminary API documentation for these elements, download the <a |
Robert Ly | 2f48339b | 2014-06-26 11:36:23 -0700 | [diff] [blame] | 114 | href="http://storage.googleapis.com/androiddevelopers/preview/l-developer-preview-reference.zip">preview |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 115 | reference</a>.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 116 | |
| 117 | <h2 id="Behaviors">Important Behavior Changes</h2> |
| 118 | |
| 119 | <p>If you have previously published an app for Android, be aware that your app |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 120 | might be affected by changes in the upcoming release.</p> |
| 121 | |
| 122 | <h3 id="ART">New Android Runtime (ART)</h3> |
| 123 | |
| 124 | <p>The 4.4 release introduced a new, experimental Android runtime, ART. Under |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 125 | 4.4, ART was optional, and the default runtime remained Dalvik. With the L |
| 126 | Developer Preview, ART is now the default runtime.</p> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 127 | |
| 128 | <p>For an overview of ART's new features, see |
| 129 | <a href="https://source.android.com/devices/tech/dalvik/art.html">Introducing |
| 130 | ART</a>. Some of the major new features are:</p> |
| 131 | |
| 132 | <ul> |
| 133 | <li>Ahead-of-Time (AOT) compilation</li> |
| 134 | <li>Improved garbage collection (GC)</li> |
| 135 | <li>Improved debugging support</li> |
| 136 | </ul> |
| 137 | |
| 138 | <p>Most Android apps should just work without change under ART. However, some |
| 139 | techniques that work on Dalvik do not work on ART. For information about the |
| 140 | most important issues, see |
| 141 | <a href="{@docRoot}guide/practices/verifying-apps-art.html">Verifying App |
| 142 | Behavior on the Android Runtime (ART)</a>. Pay particular attention if:</p> |
| 143 | |
| 144 | <ul> |
| 145 | <li>Your app uses Java Native Interface (JNI) to run C/C++ code.</li> |
| 146 | <li>You use development tools that generate non-standard code (such as some |
| 147 | obfuscators).</li> |
| 148 | <li>You use techniques that are incompatible with compacting garbage |
| 149 | collection. (ART does not currently implement compacting GC, but |
| 150 | compacting GC is under development in the Android Open-Source |
| 151 | Project.)</li> |
| 152 | </ul> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 153 | |
| 154 | <h3 id="BehaviorNotifications">If your app implements notifications...</h3> |
| 155 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 156 | <p>Notifications are drawn with dark text atop white (or very light) |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 157 | backgrounds to match the new material design widgets. Make sure that all your |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 158 | notifications look right with the new color scheme:</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 159 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 160 | <div class="figure" style="width:320px"> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 161 | <img src="images/hun-example.png" |
| 162 | srcset="images/hun-example@2x.png 2x" |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 163 | alt="" width="320" height="541" id="figure1" /> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 164 | <p class="img-caption"> |
| 165 | <strong>Figure 1.</strong> Fullscreen activity showing a heads-up notification |
| 166 | </p> |
| 167 | </div> |
| 168 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 169 | <ul> |
| 170 | |
| 171 | <li>Update or remove assets that involve color.</li> |
| 172 | |
| 173 | <li>The system automatically inverts action icons in notifications. Use |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 174 | {@code android.app.Notification. Builder.setColor()} to set an accent color |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 175 | in a circle behind your {@link android.app.Notification#icon} image.</li> |
| 176 | |
| 177 | <li>The system ignores all non-alpha channels in action icons and the main |
| 178 | notification icon. You should assume that these icons are alpha-only.</li> |
| 179 | |
| 180 | </ul> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 181 | |
| 182 | <p>If you are currently adding sounds and vibrations to your notifications by |
| 183 | using the {@link android.media.Ringtone}, {@link android.media.MediaPlayer}, |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 184 | or {@link android.os.Vibrator} classes, remove this code so that |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 185 | the system can present notifications correctly in Do |
| 186 | not Disturb mode. Instead, use the {@link android.app.Notification.Builder} |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 187 | methods instead to add sounds and vibration.</p> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 188 | |
| 189 | <p>Notifications now appear in a small floating window |
| 190 | (also called a <em>heads-up notification</em>) when the device is active |
| 191 | (that is, the device is unlocked and its screen is on). These notifications |
| 192 | appear similar to the compact form of your notification, except that the |
| 193 | heads-up notification also shows action buttons. Users can act on, or dismiss, |
| 194 | a heads-up notification without leaving the current app.</p> |
| 195 | |
| 196 | <p>Examples of conditions that may trigger heads-up notifications include:</p> |
| 197 | |
| 198 | <ul> |
| 199 | <li>The user's activity is in fullscreen mode (the app uses |
| 200 | {@link android.app.Notification#fullScreenIntent}), or</li> |
| 201 | <li>The notification has high priority and uses ringtones or |
| 202 | vibrations</li> |
| 203 | </ul> |
| 204 | |
| 205 | <p>If your app implements notifications under those scenarios, make sure that |
| 206 | heads-up notifications are presented correctly.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 207 | |
| 208 | <h3 id="BehaviorMediaControl">If your app uses RemoteControlClient...</h3> |
| 209 | |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 210 | <p>Lockscreens in the L Developer Preview do not show transport controls for |
| 211 | your {@link android.media.RemoteControlClient}. Instead, your app can provide |
| 212 | media playback control from the lockscreen through a notification. This |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 213 | gives your app more control over the presentation of media buttons, while |
| 214 | providing a consistent experience for users across the lockscreen and |
Quddus Chong | d50a6f8 | 2014-06-15 12:13:18 -0700 | [diff] [blame] | 215 | unlocked device.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 216 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 217 | <p>The L Developer Preview introduces a new |
| 218 | {@code android.app.Notification.MediaStyle} template which is recommended for |
| 219 | this purpose. {@code MediaStyle} converts notification actions that you added |
| 220 | with |
| 221 | {@link android.app.Notification.Builder#addAction(int, java.lang.CharSequence, |
| 222 | android.app.PendingIntent) |
| 223 | Notification.Builder.addAction()} into compact buttons embedded in your app's |
| 224 | media playback notifications.</p> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 225 | |
| 226 | <p>If you are using the new |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 227 | {@code android.media.session.MediaSession} class |
| 228 | (see <a href="#MediaPlaybackControl">Media Playback Control</a> below), attach |
| 229 | your session token with {@code Notification.MediaStyle.setMediaToken()} to |
| 230 | inform the system that this notification controls an ongoing media session.</p> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 231 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 232 | <p>Call {@code |
| 233 | Notification.Builder.setVisibility(Notification.VISIBILITY_PUBLIC)} to mark a |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 234 | notification as safe to show atop any lockscreen (secure or otherwise). For more |
| 235 | information, see <a href="#LockscreenNotifications">Lockscreen Notifications</a>.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 236 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 237 | <h3 id="BehaviorGetRecentTasks">If your app uses ActivityManager.getRecentTasks()...</h3> |
| 238 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 239 | <p>With the introduction of the new <em>concurrent documents and activities |
| 240 | tasks</em> feature in the upcoming release (see <a href="#Recents">Concurrent |
| 241 | documents and activities in Recents screen</a> below), |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 242 | the {@link android.app.ActivityManager#getRecentTasks |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 243 | ActivityManager.getRecentTasks()} method is now deprecated to improve user |
| 244 | privacy. For backward compatibility, this method still returns a small subset of |
| 245 | its data, including the calling application’s own tasks and possibly some other |
| 246 | non-sensitive tasks (such as Home). If your app is using this method to retrieve |
| 247 | its own tasks, use {@code android.app.ActivityManager.getAppTasks()} instead to |
| 248 | retrieve that information.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 249 | |
Quddus Chong | 20dad64d | 2014-07-18 13:21:48 -0700 | [diff] [blame] | 250 | <h3 id="64BitSupport">If you are using the Android Native Development Kit (NDK)...</h3> |
| 251 | |
| 252 | <p>The L Developer Preview introduces support for 64-bit systems and other |
| 253 | preview NDK APIs. The 64-bit enhancement adds needed address space as Android |
| 254 | usage diversifies and increases performance while still supporting existing |
| 255 | 32-bit apps fully. Use of OpenSSL for cryptography in the platform is also |
| 256 | faster. In addition, this release introduces new native audio and media NDK |
| 257 | APIs and native OpenGL ES (GLES) 3.1 support.</p> |
| 258 | |
| 259 | <p>To use this enhancement, download and install NDK Revision 10 from the |
| 260 | <a href="{@docRoot}tools/sdk/ndk/index.html">Android NDK page</a>. Refer to the |
| 261 | Revision 10 <a href="{@docRoot}tools/sdk/ndk/index.html#Revisions">release notes</a> |
| 262 | for more information about important changes and bug fixes to the NDK.</p> |
| 263 | |
| 264 | <p>If you are using the NDK and want to use the features provided in the L |
| 265 | Developer Preview, download the {@code android-ndk64-r10} package for your |
| 266 | target platform. Due to a |
| 267 | <a href="https://code.google.com/p/android/issues/detail?id=73705">known issue</a>, |
| 268 | you must still download the 64-bit package even if you only want to compile |
| 269 | apps for 32-bit systems. The package also includes |
| 270 | the {@code gcc-4.9} compiler for both 32- and 64-bit apps. The L Developer |
| 271 | Preview API library is located under the {@code platforms/android-L/} API directory.</p> |
| 272 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 273 | <h2 id="UI">User Interface</h2> |
| 274 | |
| 275 | <h3 id="MaterialDesign">Material design support</h3> |
| 276 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 277 | <p>The upcoming release adds support for Android's new <em>material</em> design |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 278 | style. You can create apps with material design that are visually dynamic and |
| 279 | have UI element transitions that feel natural to users. This support includes:</p> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 280 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 281 | <ul> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 282 | |
| 283 | <li>The material theme</li> |
Ricardo Cervera | d3e426b | 2014-06-15 16:01:28 -0700 | [diff] [blame] | 284 | <li>View shadows</li> |
| 285 | <li>The {@code RecyclerView} widget</li> |
| 286 | <li>Drawable animation and styling effects</li> |
| 287 | <li>Material design animation and activity transition effects</li> |
| 288 | <li>Animators for view properties based on the state of a view</li> |
| 289 | <li>Customizable UI widgets and app bars with color palettes that you control</li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 290 | </ul> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 291 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 292 | <p>To learn more about adding material design functionality to your app, see |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 293 | <a href="{@docRoot}preview/material/index.html">Material Design</a>.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 294 | |
| 295 | <h3 id="LockscreenNotifications">Lockscreen notifications</h3> |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 296 | <p>Lockscreens in the L Developer Preview have the ability to present |
| 297 | notifications. Users can choose via <em>Settings</em> whether to allow |
| 298 | sensitive notification content to be shown over a secure lockscreen.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 299 | |
| 300 | <p>Your app can control the level of detail visible when its notifications are |
Ricardo Cervera | d3e426b | 2014-06-15 16:01:28 -0700 | [diff] [blame] | 301 | displayed over the secure lockscreen. To control the visibility level, call |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 302 | {@code android.app.Notification.Builder.setVisibility()} and specify one of these |
| 303 | values:</p> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 304 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 305 | <ul> |
| 306 | <li>{@code VISIBILITY_PRIVATE}. Shows basic information, such as the |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 307 | notification’s icon, but hides the notification’s full content.</li> |
| 308 | <li>{@code VISIBILITY_PUBLIC}. Shows the notification’s full content.</li> |
| 309 | <li>{@code VISIBILITY_SECRET}. Shows nothing, excluding even the |
| 310 | notification’s icon.</li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 311 | </ul> |
| 312 | |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 313 | <p>When {@code VISIBILITY_PRIVATE} is set, you can also provide a redacted |
| 314 | version of the notification content that hides personal details. For example, |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 315 | an SMS app might display a notification that shows "You have 3 new text messages." |
| 316 | but hides the message content and senders. To provide this alternative |
| 317 | notification, first create the replacement notification using |
| 318 | {@link android.app.Notification.Builder}. When you create the private |
| 319 | notification object, attach the replacement notification to it through the |
| 320 | {@code Notification.Builder.setPublicVersion()} method.</p> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 321 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 322 | <h3 id="NotificationsMetadata">Notifications metadata</h3> |
| 323 | <p>The L Developer Preview uses metadata associated with your app notifications |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 324 | to sort the notifications more intelligently. To set the metadata, call the |
| 325 | following methods in {@code android.app.Notification.Builder} when you |
| 326 | construct the notification:</p> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 327 | |
| 328 | <ul> |
| 329 | <li>{@code setCategory()}. Depending on the message category, this tells |
| 330 | the system how to handle your app notifications when the device is |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 331 | in <em>Do not Disturb</em> mode (for example, if your notification represents an |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 332 | incoming call, instant message, or alarm). |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 333 | <li>{@code setPriority()}. Notifications with the priority field set to |
| 334 | {@code PRIORITY_MAX} or {@code PRIORITY_HIGH} will appear in a small floating |
Ricardo Cervera | d3e426b | 2014-06-15 16:01:28 -0700 | [diff] [blame] | 335 | window if the notification also has sound or vibration.</li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 336 | <li>{@code addPerson()}. Allows you to add a list of people to a notification. |
| 337 | Your app can use this to signal to the system that it should group together |
| 338 | notifications from the specified people, or rank notifications from these |
Ricardo Cervera | d3e426b | 2014-06-15 16:01:28 -0700 | [diff] [blame] | 339 | people as being more important.</li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 340 | </ul> |
| 341 | |
Ricardo Cervera | d3e426b | 2014-06-15 16:01:28 -0700 | [diff] [blame] | 342 | <h3 id="Recents">Concurrent documents and activities in the Recents screen</h3> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 343 | |
| 344 | <p>In previous releases, the |
| 345 | <a href="{@docRoot}design/get-started/ui-overview.html">Recents screen</a> |
| 346 | could only display a single task for each app that the user interacted with |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 347 | most recently. Now your app can open more tasks as |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 348 | needed for additional concurrent activities for documents. |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 349 | This feature facilitates multitasking by letting users quickly switch between |
| 350 | individual activities and documents from the Recents screen, with a consistent |
| 351 | switching experience across all apps. |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 352 | Examples of such concurrent tasks might include open tabs in a web |
| 353 | browser app, documents in a productivity app, concurrent matches in |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 354 | a game, or chats in a messaging app. Your app can manage its tasks |
| 355 | through the {@code android.app.ActivityManager.AppTask} class.</p> |
| 356 | |
| 357 | <p>To insert a logical break so that the system treats your activity as a new |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 358 | task, use {@code android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT} when |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 359 | launching the activity with {@link android.app.Activity#startActivity(android.content.Intent) |
| 360 | startActivity()}. You can also get this behavior by declaring the |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 361 | <a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a> |
| 362 | attribute {@code documentLaunchMode="intoExisting"} or {@code ="always"} in your |
| 363 | manifest.</p> |
| 364 | |
| 365 | <p>You can also mark that a task should be removed from the Recents screen |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 366 | when all its activities are closed. To do this, use {@code |
| 367 | android.content.Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS} when starting the |
| 368 | root activity for |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 369 | the task. You can also set this behavior for an activity by declaring the |
| 370 | <a href="{@docRoot}guide/topics/manifest/activity-element.html"><activity></a> |
| 371 | attribute {@code autoRemoveFromRecents=“true”} in your manifest.</p> |
| 372 | |
| 373 | <p>To avoid cluttering the Recents screen, you can set the maximum number of |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 374 | tasks from your app that can appear in that screen. To do this, set the |
| 375 | <a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a> |
| 376 | attribute {@code android:maxRecent}. The current maximum that can be specified |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 377 | is 100 tasks per user.</a></p> |
| 378 | |
| 379 | <h3 id="WebView">WebView updates</h3> |
| 380 | <p>The L Developer Preview updates the {@link android.webkit.WebView} |
| 381 | implementation to Chromium M36, bringing security and stability enhancements, |
| 382 | as well as bug fixes. The default user-agent string for a |
| 383 | {@link android.webkit.WebView} running on the L Developer Preview has |
| 384 | been updated to incorporate 36.0.0.0 as the version number.</p> |
| 385 | |
| 386 | <p>Additionally, this release brings support for the |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 387 | <a href="http://webaudio.github.io/web-audio-api/" class="external-link">WebAudio</a>, |
| 388 | <a href="https://www.khronos.org/webgl/" class="external-link">WebGL</a>, and |
| 389 | <a href="http://www.webrtc.org/" class="external-link">WebRTC</a> open standards. To learn more about |
| 390 | the new features included in this release, see <a href="https://developer.chrome.com/multidevice/webview/overview" class="external-link">WebView for Android</a>.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 391 | |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 392 | <h2 id="Graphics">Graphics</h2> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 393 | |
| 394 | <h3 id="OpenGLES-3-1">Support for OpenGL ES 3.1</h3> |
| 395 | <p>The L Developer Preview adds Java interfaces and native support for OpenGL |
| 396 | ES 3.1. Key new functionality provided in OpenGL ES 3.1 includes:</p> |
| 397 | |
| 398 | <ul> |
| 399 | <li>Compute shaders |
| 400 | <li>Separate shader objects |
| 401 | <li>Indirect draw commands |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 402 | <li>Multisample and stencil textures |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 403 | <li>Shading language improvements |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 404 | <li>Extensions for advanced blend modes and debugging |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 405 | <li>Backward compatibility with OpenGL ES 2.0 and 3.0 |
| 406 | </ul> |
| 407 | |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 408 | <p>The Java interface for OpenGL ES 3.1 on Android is provided with {@code GLES31}. When |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 409 | using OpenGL ES 3.1, be sure that you declare it in your manifest file with the |
| 410 | <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a> |
David Friedman | 8dcf1c3 | 2014-09-18 18:24:49 -0700 | [diff] [blame] | 411 | tag and the {@code android:glEsVersion} attribute. For example:</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 412 | |
| 413 | <pre> |
| 414 | <manifest> |
| 415 | <uses-feature android:glEsVersion="0x00030001" /> |
| 416 | ... |
| 417 | </manifest> |
| 418 | </pre> |
| 419 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 420 | <p>For more information about using OpenGL ES, including how to check the |
| 421 | device’s supported OpenGL ES version at runtime, see the |
| 422 | <a href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL ES API guide</a>.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 423 | |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 424 | <h3 id="AndroidExtensionPack">Android Extension Pack</h3> |
| 425 | |
| 426 | <p>In addition to OpenGL ES 3.1, this release provides an extension pack with Java interfaces and |
| 427 | native support for advanced graphics functionality. These extensions are treated as a single |
| 428 | package by Android. (If the {@code ANDROID_extension_pack_es31} extension is present, your app can |
| 429 | assume all extensions in the package are present and enable the shading language features with |
| 430 | a single {@code #extension} statement.</p> |
| 431 | <p>The extension pack supports:</p> |
| 432 | <ul> |
| 433 | <li>Guaranteed fragment shader support for shader storage buffers, images, and |
| 434 | atomics (fragment shader support is optional in OpenGL ES 3.1.)</li> |
| 435 | <li>Tessellation and geometry shaders</li> |
| 436 | <li>ASTC (LDR) texture compression format</li> |
| 437 | <li>Per-sample interpolation and shading</li> |
| 438 | <li>Different blend modes for each color attachment in a frame buffer</li> |
| 439 | </ul> |
| 440 | |
| 441 | <p>The Java interface for the extension pack is provided with {@code GLES31Ext}. |
| 442 | In your app manifest, you can declare that support for the extension pack is |
| 443 | required, with the |
| 444 | <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a> |
| 445 | tag, but the precise syntax is not finalized in the L Developer Preview.</p> |
| 446 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 447 | <h2 id="Multimedia">Multimedia</h2> |
| 448 | |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 449 | <h3 id="Camera-v2">Camera API for advanced camera capabilities</h3> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 450 | |
| 451 | <p>The L Developer Preview introduces the new {@code android.hardware.camera2} |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 452 | API to facilitate fine-grain photo capture and image processing. You can now |
| 453 | programmatically access the camera devices available to the system with {@code |
| 454 | CameraManager.getCameraIdList()} and connect to a specific device with {@code |
| 455 | CameraManager.openCamera()}. To start capturing images, create a {@code |
| 456 | CameraCaptureSession} and specify the {@link android.view.Surface} objects for |
| 457 | the captured images. The {@code CameraCaptureSession} can be configured to take |
| 458 | single shots or multiple images in a burst.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 459 | |
| 460 | <p>To be notified when new images are captured, implement the |
| 461 | {@code CameraCaptureSession.CaptureListener()} interface and set it in your |
| 462 | capture request. Now when the system completes the image capture request, your |
| 463 | {@code CameraCaptureSession.CaptureListener()} receives a call to |
| 464 | {@code onCaptureCompleted()}, providing you with the image capture metadata in a |
| 465 | {@code CaptureResult}.</p> |
| 466 | |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 467 | <p>To see an example of how to use the updated Camera API, refer to the {@code Camera2Basic} |
| 468 | and {@code Camera2Video} implementation samples in this release.</p> |
| 469 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 470 | <h3 id="AudioPlayback">Audio playback</h3> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 471 | <p>This release includes the following changes to |
| 472 | {@link android.media.AudioTrack}:</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 473 | <ul> |
| 474 | <li>Your app can now supply audio data in floating-point format |
| 475 | ({@code android.media.AudioFormat.ENCODING_PCM_FLOAT}). This permits greater |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 476 | dynamic range, more consistent precision, and greater headroom. Floating-point |
| 477 | arithmetic is especially useful during intermediate calculations. Playback |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 478 | end-points use integer format for audio data, and with lower bit-depth. (In the |
| 479 | L Developer Preview, portions of the internal pipeline are not yet |
| 480 | floating-point.) |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 481 | <li>Your app can now supply audio data as a {@link java.nio.ByteBuffer}, in |
| 482 | the same format as provided by {@link android.media.MediaCodec}. |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 483 | <li>The {@code WRITE_NON_BLOCKING} option can simplify buffering and |
| 484 | multithreading for some apps. |
| 485 | </ul> |
| 486 | |
| 487 | <h3 id="MediaPlaybackControl">Media playback control</h3> |
| 488 | <p>You can now build your own media controller app with the new |
| 489 | {@code android.media.session.MediaController} class, which provides |
| 490 | simplified transport controls APIs that replace those in |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 491 | {@link android.media.RemoteControlClient}. The {@code MediaController} class |
| 492 | allows thread-safe control of playback from a non-UI process, making it easier |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 493 | to control your media playback service from your app’s user interface. |
| 494 | |
| 495 | <p>You can also create multiple controllers to send playback commands, |
| 496 | media keys, and other events to the same ongoing |
| 497 | {@code android.media.session.MediaSession}. When you add a controller, you must |
| 498 | call {@code MediaSession.getSessionToken()} to request an access |
| 499 | token in order for your app to interact with the session.</p> |
| 500 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 501 | <p>You can now send transport commands such as "play", "stop", "skip", and |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 502 | "set rating" by using {@code MediaController.TransportControls}. To handle |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 503 | in-bound media transport commands from controllers attached to the session, |
| 504 | override the callback methods in |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 505 | {@code MediaSession.TransportControlsCallback}.</p> |
| 506 | |
| 507 | <p>You can also create rich notifications that allow playback control tied to a |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 508 | media session with the new {@code android.app.Notification.MediaStyle} class. By |
| 509 | using the new notification and media APIs, you will ensure that the System UI |
| 510 | knows about your playback and can extract and show album art.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 511 | |
| 512 | <h2 id="Storage">Storage</h2> |
| 513 | |
| 514 | <h3 id="DirectorySelection">Directory selection</h3> |
| 515 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 516 | <p>The L Developer Preview extends the <a href="{@docRoot}guide/topics/providers/document-provider.html">Storage Access Framework</a> to let users select an entire directory subtree, |
| 517 | giving apps read/write access to all contained documents without requiring user |
| 518 | confirmation for each item.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 519 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 520 | <p>To select a directory subtree, build and send an |
| 521 | {@code android.intent.action.OPEN_DOCUMENT_TREE} {@link android.content.Intent}. |
| 522 | The system displays all |
| 523 | {@link android.provider.DocumentsProvider} instances that support subtree selection, |
| 524 | letting the user browse and select a directory. The returned URI represents access to the selected |
| 525 | subtree. You can then use {@code DocumentsContract.buildChildDocumentsUriUsingTree()} |
| 526 | and {@code DocumentsContract.buildDocumentUriUsingTree()} along with |
| 527 | {@code ContentResolver.query()} to explore the subtree.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 528 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 529 | <p>The new {@code DocumentsContract.createDocument()} method lets you create |
| 530 | new documents or directories anywhere under the subtree. To manage |
| 531 | existing documents, use {@code DocumentsContract.renameDocument()} and |
| 532 | {@code DocumentsContract.deleteDocument()}. Check {@code DocumentsContract.Document.COLUMN_FLAGS} |
| 533 | to verify provider support for these calls before issuing them.</p> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 534 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 535 | <p>If you're implementing a {@link android.provider.DocumentsProvider} and want |
| 536 | to support subtree selection, implement {@code DocumentsProvider.isChildDocument()} |
| 537 | and include {@code Documents.Contract.FLAG_SUPPORTS_IS_CHILD} in your |
| 538 | {@code Root.COLUMN_FLAGS}.</p> |
| 539 | |
| 540 | <p>The L Developer Preview also introduces new package-specific directories on |
| 541 | shared storage where your app can place media files for inclusion in |
| 542 | {@link android.provider.MediaStore}. The new |
| 543 | {@code android.content.Context.getExternalMediaDirs()} returns paths to these |
| 544 | directories on all shared storage devices. Similarly to |
| 545 | {@link android.content.Context#getExternalFilesDir(java.lang.String) Context.getExternalFilesDir()}, |
| 546 | no additional permissions are needed by your app to access the returned paths. The |
| 547 | platform periodically scans for new media in these directories, but you can also |
| 548 | use {@link android.media.MediaScannerConnection} to explicitly scan for new |
| 549 | content.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 550 | |
| 551 | <h2 id="Wireless">Wireless & Connectivity</h2> |
| 552 | |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 553 | <h3 id="Multinetwork">Multiple network connections</h3> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 554 | <p>The L Developer Preview provides new multi-networking APIs. These let your app |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 555 | dynamically scan for available networks with specific capabilities, and |
| 556 | establish a connection to them. This is useful when your app requires a |
| 557 | specialized network, such as an SUPL, MMS, or carrier-billing network, or if |
| 558 | you want to send data using a particular type of transport protocol.</p> |
| 559 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 560 | <p>To select and connect to a network dynamically from your app follow these |
| 561 | steps:</p> |
| 562 | |
| 563 | <ol> |
| 564 | <li>Create a {@link android.net.ConnectivityManager}.</li> |
| 565 | <li>Create a |
| 566 | {@code android.net.NetworkRequest} to specify the network features and transport |
| 567 | type your app is interested in.</li> |
| 568 | <li>To scan for suitable networks, call |
| 569 | {@code ConnectivityManager.requestNetwork()} or |
| 570 | {@code ConnectivityManager.registerNetworkCallback()}, and pass in the |
| 571 | {@code NetworkRequest} object and an implementation of |
| 572 | {@code ConnectivityManager.NetworkCallbackListener}.</li> |
| 573 | |
| 574 | </ol> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 575 | |
| 576 | <p>When the system detects a suitable network, it connects to the network and |
| 577 | invokes the {@code NetworkCallbackListener.onAvailable()} callback. You can use |
| 578 | the {@code android.net.Network} object from the callback to get additional |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 579 | information about the network, or to direct traffic to use the selected |
| 580 | network.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 581 | |
| 582 | <h3 id="BluetoothBroadcasting">Bluetooth broadcasting</h3> |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 583 | <p>Android 4.3 introduced platform support for |
| 584 | <a href="{@docRoot}guide/topics/connectivity/bluetooth-le.html">Bluetooth Low Energy</a> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 585 | (BLE) in the central role. In the L Developer Preview, an Android device can now |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 586 | act as a Bluetooth LE <em>peripheral device</em>. Apps can use this capability |
| 587 | to make their presence known to |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 588 | nearby devices. For instance, you can build apps that allow a device to |
| 589 | function as a pedometer or health monitor and communicate its data with another |
| 590 | BLE device.</p> |
| 591 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 592 | <p>The new {@code android.bluetooth.le} APIs enable your apps to broadcast |
| 593 | advertisements, scan for responses, and form connections with nearby BLE devices. |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 594 | You must add the {@code android.permission.BLUETOOTH_ADMIN} permission in your |
| 595 | manifest in order for your app to use the new advertising and scanning features.</a> |
| 596 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 597 | <p>To begin Bluetooth LE advertising so that other devices can discover |
Quddus Chong | 6a5dd93 | 2014-07-11 11:55:23 -0700 | [diff] [blame] | 598 | your app, call {@code android.bluetooth.le.BluetoothAdvertiser.startAdvertising()} |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 599 | and pass in an implementation of the |
| 600 | {@code android.bluetooth.le.AdvertiseCallback} class. The callback object |
| 601 | receives a report of the success or failure of the advertising operation.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 602 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 603 | <p> The L Developer Preview introduces the {@code |
| 604 | android.bluetooth.le.ScanFilter} class so that your app can scan for only the |
| 605 | specific types of devices it is interested in. To begin scanning for Bluetooth |
| 606 | LE devices, call {@code android.bluetooth.le.BluetoothLeScanner.startScan()} and |
| 607 | pass in a list of filters. In the method call, you must also provide an |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 608 | implementation of {@code android.bluetooth.le.ScanCallback} to report if a |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 609 | Bluetooth LE advertisement is found. </p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 610 | |
| 611 | <h3 id="NFCEnhancements">NFC enhancements</h3> |
| 612 | <p>The L Developer Preview adds these enhancements to enable wider and more |
| 613 | flexible use of NFC:</p> |
| 614 | |
| 615 | <ul> |
| 616 | <li>Android Beam is now available in the share menu. |
| 617 | <li>Your app can invoke the Android Beam on the user’s device to share data by |
| 618 | calling {@code android.nfc.NfcAdapter.invokeBeam()}. This avoids the need for |
| 619 | the user to manually tap the device against another NFC-capable device to |
| 620 | complete the data transfer. |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 621 | <li>You can use the new {@code android.nfc.NdefRecord.createTextRecord()} method |
| 622 | to create an NDEF record containing UTF-8 text data. |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 623 | <li>If you are developing a payment app, you now have the ability to |
| 624 | register an NFC application ID (AID) dynamically by calling |
| 625 | {@code android.nfc.cardemulation.CardEmulation.registerAidsForService()}. |
| 626 | You can also use {@code android.nfc.cardemulation.CardEmulation.setPreferredService()} |
| 627 | to set the preferred card emulation service that should be used when a specific |
| 628 | activity is in the foreground. |
| 629 | </ul> |
| 630 | |
| 631 | <h2 id="Power">Power Efficiency</h2> |
| 632 | |
| 633 | <h3 id="JobScheduler">Scheduling jobs</h3> |
| 634 | <p>The L Developer Preview provides a new {@code android.app.job.JobScheduler} |
Quddus Chong | d50a6f8 | 2014-06-15 12:13:18 -0700 | [diff] [blame] | 635 | API that lets you optimize battery life by defining jobs for the system to run |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 636 | asynchronously at a later time or under specified conditions (such as when the |
| 637 | device is charging). This is useful in such situations as:</p> |
| 638 | <ul> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 639 | <li>The app has non-user-facing work that you can defer.</li> |
| 640 | <li>The app has work you'd prefer to do when the unit is plugged in.</li> |
| 641 | <li>The app has a task that requires network access (or requires a Wi-Fi |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 642 | connection).</li> |
| 643 | <li>The app has a number of tasks that you want to run as a batch on a regular |
| 644 | schedule.</li> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 645 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 646 | </ul> |
| 647 | |
| 648 | <p>A unit of work is encapsulated by a {@code android.app.job.JobInfo} object. |
| 649 | This object provides an exact description of the criteria to be used for |
| 650 | scheduling.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 651 | |
| 652 | <p>Use the {@code android.app.job.JobInfo.Builder} to configure how the |
| 653 | scheduled task should run. You can schedule the task to run under specific |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 654 | conditions, such as:</p> |
| 655 | |
| 656 | <ul> |
| 657 | <li>The device is charging</li> |
| 658 | <li>The device is connected to an unmetered network</li> |
| 659 | <li>The system deems the device to be idle</li> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 660 | <li>Completion with a minimum delay or within a specific deadline.</li> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 661 | </ul> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 662 | |
| 663 | <p>For example, you can add code like this to run your task on an |
| 664 | unmetered network:</p> |
| 665 | |
| 666 | <pre> |
| 667 | JobInfo uploadTask = new JobInfo.Builder(mJobId, mServiceComponent) |
| 668 | .setRequiredNetworkCapabilities(JobInfo.NetworkType.UNMETERED) |
| 669 | .build(); |
| 670 | |
| 671 | JobScheduler jobScheduler = |
| 672 | (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE) |
| 673 | jobScheduler.schedule(uploadTask); |
| 674 | </pre> |
| 675 | |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 676 | <p>To see an example of how to use the {@code JobScheduler} API, refer to the |
| 677 | {@code JobSchedulerSample} implementation sample in this release.</p> |
| 678 | |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 679 | <h3 id="PowerMeasurementTools">Developer tools for power measurement</h3> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 680 | <p>The L Developer Preview provides several new developer tools and APIs to help |
| 681 | you better measure and understand your app's power usage.</p> |
| 682 | |
| 683 | <dl> |
| 684 | <dt><strong>batterystats</strong></dt> |
| 685 | <dd> |
| 686 | <p>The {@code dumpsys batterystats} command allows you to generate interesting |
| 687 | statistical data about battery usage on a device, organized by unique user ID |
| 688 | (UID). The statistics generated by the tool include:</p> |
| 689 | |
| 690 | <ul> |
| 691 | <li>History of battery related events |
| 692 | <li>Global statistics for the device |
| 693 | <li>Approximated power use per UID and system component |
| 694 | <li>Per-app mobile ms per packet |
| 695 | <li>System UID aggregated statistics |
| 696 | <li>App UID aggregated statistics |
| 697 | </ul> |
| 698 | |
Quddus Chong | d50a6f8 | 2014-06-15 12:13:18 -0700 | [diff] [blame] | 699 | <p>Use the {@code --help} option to learn about the various options for |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 700 | tailoring the output. For example, to print battery usage |
| 701 | statistics for a given app package since the device was last charged, run this |
Quddus Chong | d50a6f8 | 2014-06-15 12:13:18 -0700 | [diff] [blame] | 702 | command: |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 703 | <pre> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 704 | $ adb shell dumpsys batterystats --charged <package-name> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 705 | </pre> |
| 706 | </dd> |
| 707 | |
| 708 | <dt><strong>Battery Historian</strong></dt> |
| 709 | <dd> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 710 | <p>The Battery Historian tool ({@code historian.par}) analyzes Android |
| 711 | bug reports from the L Developer Preview and creates an HTML visualization of |
| 712 | power-related events. It can |
| 713 | also visualize power consumption data from a power monitor, and attempts to |
| 714 | map power usage to the wake locks seen. You can find the Battery Historian tool |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 715 | in {@code <sdk>/tools}.</p> |
| 716 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 717 | <img src="images/battery_historian.png" |
| 718 | srcset="images/battery_historian@2x.png 2x" |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 719 | alt="" width="760" height="462" |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 720 | id="figure2" /> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 721 | <p class="img-caption"> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 722 | <strong>Figure 2.</strong>HTML visualization generated by the Battery |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 723 | Historian tool. |
| 724 | </p> |
| 725 | |
| 726 | <p>For best results, you should first enable full wake lock reporting, to allow |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 727 | the Battery Historian tool to monitor uninterrupted over an extended period of |
| 728 | time:</p> |
| 729 | <pre> |
| 730 | $ adb shell dumpsys batterystats --enable full-wake-history |
| 731 | </pre> |
| 732 | |
| 733 | <p>You should also reset battery statistics at the beginning of a |
| 734 | measurement:</p> |
| 735 | <pre> |
| 736 | $ adb shell dumpsys batterystats --reset |
| 737 | </pre> |
| 738 | |
| 739 | <p>To generate an HTML visualization:</p> |
| 740 | <pre> |
| 741 | $ historian.par [-p powerfile] bugreport.txt > out.html |
| 742 | </pre> |
| 743 | </dd> |
| 744 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 745 | </dl> |
| 746 | |
| 747 | <h2 id="Enterprise">Enterprise</h2> |
| 748 | <h3 id="ManagedProvisioning">Managed provisioning</h3> |
| 749 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 750 | <div class="figure" style="width:360px"> |
| 751 | <img src="images/managed_apps_launcher.png" |
| 752 | srcset="images/managed_apps_launcher@2x.png 2x" |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 753 | alt="" width="360" height="609" id="figure3" /> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 754 | <p class="img-caption"> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 755 | <strong>Figure 3.</strong> Launcher screen showing managed apps (marked with |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 756 | a lock badge) |
| 757 | </p> |
| 758 | </div> |
| 759 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 760 | <p>The L Developer Preview provides new functionality for running apps within |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 761 | an enterprise environment. A |
| 762 | <a href="{@docRoot}guide/topics/admin/device-admin.html">device administrator</a> can |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 763 | initiate a managed provisioning process to add a co-present but separate <em>managed profile</em> to a device, if the user has an existing personal account. |
| 764 | Apps that are associated with managed profiles will appear alongside |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 765 | non-managed apps in the user’s Launcher, Recent apps screen, and notifications.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 766 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 767 | <p>To start the managed provisioning process, send {@code |
| 768 | ACTION_PROVISION_MANAGED_PROFILE} in an {@link android.content.Intent}. If the |
| 769 | call is successful, the system triggers the {@code |
| 770 | android.app.admin.DeviceAdminReceiver. onProfileProvisioningComplete()} callback. |
| 771 | You can then call {@code app.admin.DevicePolicyManager. setProfileEnabled()} to |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 772 | enable this managed profile.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 773 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 774 | <p>If you are developing a Launcher app, you can use the new {@code |
| 775 | android.content.pm.LauncherApps} class to get a list of launchable activities |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 776 | for the current user and any associated managed profiles. Your Launcher can make |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 777 | the managed apps visually prominent by appending a “work” badge to the icon |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 778 | drawable with {@code android.os.UserManager. getBadgeDrawableForUser()}.</p> |
| 779 | |
| 780 | <p>To see an example of how to use the new functionality, refer to the |
| 781 | {@code BasicManagedProfile} implementation sample in this release.</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 782 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 783 | <h3 id="TaskLocking">Task locking</h3> |
| 784 | <p>The L Developer Preview introduces a new task locking API that |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 785 | lets you temporarily restrict users from leaving your app or being interrupted |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 786 | by notifications. This could be used, for example, if you are developing an |
| 787 | education app to support high stakes assessment requirements on Android. |
| 788 | Once your app activates this mode, users will not be able to see |
| 789 | notifications, access other apps, or return to the Home screen, until your |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 790 | app exits the mode.</p> |
| 791 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 792 | <p>To prevent unauthorized usage, only authorized apps can activate task locking. |
| 793 | Furthermore, task locking authorization must be granted by a |
| 794 | specially-configured <em>device owner</em> app, through the {@code android.app.admin.DevicePolicyManager.setLockTaskComponents()} method.</p> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 795 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 796 | <p>To set up a device owner, follow these steps:</p> |
| 797 | <ol> |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 798 | <li>Attach a device running an Android <a href="https://source.android.com/source/building-running.html" class="external-link">{@code userdebug}</a> build to your development machine.</li> |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 799 | <li>Install your device owner app.</li> |
| 800 | <li>Create a {@code device_owner.xml} file and save it to the {@code /data/system} |
| 801 | directory on the device. |
| 802 | <pre> |
| 803 | $ adb root |
| 804 | $ adb shell stop |
| 805 | $ rm /tmp/device_owner.xml |
| 806 | $ echo "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>" |
| 807 | >> /tmp/device_owner.xml |
Quddus Chong | 9a3dd19 | 2014-07-08 10:07:43 -0700 | [diff] [blame] | 808 | $ echo "<device-owner package=\"<your_device_owner_package>\" |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 809 | name=\"*<your_organization_name>\" />" >> /tmp/device_owner.xml |
| 810 | $ adb push /tmp/device_owner.xml /data/system/device_owner.xml |
| 811 | $ adb reboot |
| 812 | </pre> |
| 813 | </li> |
| 814 | </ol> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 815 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 816 | <p>Before using the task locking API in your app, verify that your activity is |
| 817 | authorized by calling {@code DevicePolicyManager.isLockTaskPermitted()}.</p> |
| 818 | |
| 819 | <p>To activate task locking, call |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 820 | {@code android.app.Activity.startLockTask()} from your authorized activity.</p> |
| 821 | |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 822 | <p>When task locking is active, the following behavior takes effect:</p> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 823 | |
| 824 | <ul> |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 825 | <li>The status bar is blank, and user notifications and status information is |
| 826 | hidden.</li> |
| 827 | <li>The Home and Recent Apps buttons are hidden.</li> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 828 | <li>Other apps may not launch new activities.</li> |
| 829 | <li>The current app may start new activities, as long as doing so does not |
| 830 | create new tasks.</li> |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 831 | <li>The user remains locked on your app until an authorized activity calls |
| 832 | {@code Activity.stopLockTask()}.</li> |
Quddus Chong | 1730564 | 2014-06-18 12:19:06 -0700 | [diff] [blame] | 833 | </ul> |
| 834 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 835 | <h2 id="Printing">Printing Framework</h2> |
| 836 | |
| 837 | <h3 id="PDFRender">Render PDF as bitmap</h3> |
| 838 | <p>You can now render PDF document pages into bitmap images for printing by |
| 839 | using the new {@code android.graphics.pdf.PdfRenderer} class. You must specify a |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 840 | {@link android.os.ParcelFileDescriptor} that is seekable (that is, the content |
| 841 | can be randomly accessed) on which the system writes the the printable content. |
| 842 | Your app can obtain a page for rendering with {@code openPage()}, then call |
| 843 | {@code render()} to turn the opened {@code PdfRenderer.Page} into a bitmap. You |
| 844 | can also set additional parameters if you only want to convert a portion of the |
| 845 | document into a bitmap image (for example, to implement |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 846 | <a href="http://en.wikipedia.org/wiki/Tiled_rendering" class="external-link">tiled rendering</a> in |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 847 | order to zoom in on the document).</p> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 848 | |
| 849 | <h2 id="TestingA11y">Testing & Accessibility </h2> |
| 850 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 851 | <h3 id="TestingA11yImprovements">Testing and accessibility improvements</h3> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 852 | <p>The L Developer Preview adds the following support for testing and |
| 853 | accessibility:</p> |
| 854 | |
| 855 | <ul> |
| 856 | <li>You can use the new {@code android.app.UiAutomation.getWindowAnimationFrameStats()} |
| 857 | and {@code android.app.UiAutomation.getWindowContentFrameStats()} methods to |
| 858 | capture frame statistics for window animations and content. This lets you |
| 859 | write instrumentation tests to evaluate if the app under test is rendering |
| 860 | frames at a sufficient refresh frequency to provide a smooth user experience. |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 861 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 862 | <li>You can execute shell commands from your instrumentation test with the new |
| 863 | {@code android.app.UiAutomation.executeShellCommand()}. The command execution |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 864 | is similar to running {@code adb shell} from a host connected to the device. This |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 865 | allows you to use shell based tools such as {@code dumpsys}, {@code am}, |
| 866 | {@code content}, and {@code pm}. |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 867 | |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 868 | <li>Accessibility services and test tools that use the accessibility APIs |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 869 | (such as <a href="{@docRoot}tools/help/uiautomator/index.html">uiautomator</a>) |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 870 | can now retrieve detailed information about the properties of windows on the |
| 871 | screen that sighted users can interact with. To retrieve a list of |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 872 | {@code android.view.accessibility.AccessibilityWindowInfo} objects |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 873 | representing the windows information, call the new |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 874 | {@code android.accessibilityservice.AccessibilityService.getWindows()} method. |
| 875 | <li>You can use the new {@code android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction} to define standard or customized |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 876 | actions to perform on an {@link android.view.accessibility.AccessibilityNodeInfo}. |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 877 | The new {@code AccessibilityAction} class replaces the actions-related APIs |
| 878 | previously found in {@code AccessibilityNodeInfo}. |
| 879 | </ul> |
| 880 | |
Quddus Chong | 26aec76 | 2014-06-24 10:14:12 -0700 | [diff] [blame] | 881 | <h2 id="IME">IME</h2> |
| 882 | |
| 883 | <h3 id="Switching">Easier switching between input languages</h3> |
| 884 | |
| 885 | <p>Beginning in the L Developer Preview, users can more easily switch between |
| 886 | all <a href="{@docRoot}guide/topics/text/creating-input-method.html">input |
| 887 | method editors (IME)</a> supported by the platform. Performing the designated |
| 888 | switching action (usually touching a Globe icon on the soft keyboard) will cycle |
| 889 | among all such IMEs. This change takes place in |
| 890 | {@link android.view.inputmethod.InputMethodManager#shouldOfferSwitchingToNextInputMethod |
| 891 | InputMethodManager.shouldOfferSwitchingToNextInputMethod()}.</p> |
| 892 | |
| 893 | <p>In addition, the framework now checks whether the next IME includes a |
| 894 | switching mechanism at all (and, thus, whether that IME supports switching to |
| 895 | the IME after it). An |
| 896 | IME with a switching mechanism will not cycle to an IME without one. This |
| 897 | change takes place in |
| 898 | {@link android.view.inputmethod.InputMethodManager#switchToNextInputMethod |
| 899 | InputMethodManager.switchToNextInputMethod}. |
| 900 | |
| 901 | <p>To see an example of how to use the updated IME-switching APIs, refer to the |
| 902 | updated soft-keyboard implementation sample in this release.</p> |
| 903 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 904 | <h2 id="Manifest">Manifest Declarations</h2> |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 905 | |
| 906 | <h3 id="ManifestFeatures">Declarable required features</h3> |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 907 | <p>The following values are now supported in the |
| 908 | <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code <uses-feature>}</a> |
| 909 | element, so you can ensure that your app is installed only on devices that provide the features |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 910 | your app needs.</p> |
| 911 | |
| 912 | <ul> |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 913 | <li>{@code FEATURE_LEANBACK}. Declares that your app must be installed only on |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 914 | devices that support the |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 915 | <a href="{@docRoot}training/tv/index.html">Android TV</a> user interface. |
Quddus Chong | aa9d778 | 2014-06-19 16:16:10 -0700 | [diff] [blame] | 916 | Example: |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 917 | <pre> |
| 918 | <uses-feature android:name="android.software.leanback" |
| 919 | android:required="true" /> |
| 920 | </pre> |
| 921 | |
Andrew Solovay | 68990cf | 2014-06-15 20:26:07 -0700 | [diff] [blame] | 922 | <li>{@code FEATURE_WEBVIEW}. Declares that your app must only be installed on |
| 923 | devices that fully implement the {@code android.webkit.*} APIs. Example: |
Robert Ly | 2055529 | 2014-06-13 23:28:19 -0700 | [diff] [blame] | 924 | <pre> |
| 925 | <uses-feature android:name="android.software.webview" |
| 926 | android:required="true" /> |
| 927 | </pre> |
| 928 | </ul> |
| 929 | |
Quddus Chong | a2cc6cc | 2014-06-23 12:34:59 -0700 | [diff] [blame] | 930 | <p class="note">For a detailed view of all API changes in the L Developer Preview, see the |
| 931 | <a href="{@docRoot}preview/reference.html">API Differences Report</a>.</p> |