Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 1 | page.title=Android N for Developers |
Dirk Dougherty | 43eb951 | 2016-03-03 14:53:16 -0800 | [diff] [blame] | 2 | meta.tags="preview", "androidn" |
| 3 | page.tags="preview", "developer preview" |
Dirk Dougherty | a6495a92 | 2016-03-04 15:21:59 -0800 | [diff] [blame] | 4 | page.image=images/cards/card-n-apis_2x.png |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 5 | @jd:body |
| 6 | |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 7 | |
| 8 | |
| 9 | |
| 10 | <div id="qv-wrapper"> |
| 11 | <div id="qv"> |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 12 | <h2>Key Developer Features</h2> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 13 | <ol> |
| 14 | <ul style="list-style-type:none;"> |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 15 | <li><a href="#multi-window_support">Multi-window Support</a></li> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 16 | <li><a href="#notification_enhancements">Notifications</a></li> |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 17 | <li><a href="#jit_aot">JIT/AOT Compilation</a></li> |
| 18 | <li><a href="#quick_path_to_app_install">Quick Path to App Install</a></li> |
| 19 | <li><a href="#doze_on_the_go">Doze on the Go</a></li> |
| 20 | <li><a href="#background_optimizations">Background Optimizations</a></li> |
David Friedman | 521da6a | 2016-06-14 15:37:16 -0700 | [diff] [blame] | 21 | <li><a href="#surfaceview">SurfaceView</a></li> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 22 | <li><a href="#data_saver">Data Saver</a></li> |
Andrew Solovay | 097b115 | 2016-04-06 17:33:00 -0700 | [diff] [blame] | 23 | <li><a href="#vulkan">Vulkan API</a></li> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 24 | <li><a href="#tile_api">Quick Settings Tile API</a></li> |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 25 | <li><a href="#number-blocking">Number Blocking</a></li> |
| 26 | <li><a href="#call_screening">Call Screening</a></li> |
| 27 | <li><a href="#multi-locale_languages">Locales and Languages</a></li> |
Eric Schmidt | 700127a | 2016-05-12 16:29:18 -0700 | [diff] [blame] | 28 | <li><a href="#emoji">New Emojis</a></li> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 29 | <li><a href="#icu4">ICU4J APIs in Android</a></li> |
Andrew Solovay | 1721c3e | 2016-07-15 13:04:04 -0700 | [diff] [blame] | 30 | <li><a href="#webview">WebView</a></li> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 31 | <li><a href="#gles_32">OpenGL ES 3.2 API</a></li> |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 32 | <li><a href="#android_tv_recording">Android TV Recording</a></li> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 33 | <li><a href="#android_for_work">Android for Work</a></li> |
| 34 | <li><a href="#accessibility_enhancements">Accessibility</a></li> |
| 35 | <li><a href="#direct_boot">Direct Boot</a></li> |
| 36 | <li><a href="#key_attestation">Key Attestation</a></li> |
| 37 | <li><a href="#network_security_config">Network Security Config</a></li> |
| 38 | <li><a href="#default_trusted_ca">Default Trusted CA</a></li> |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 39 | <li><a href="#apk_signature_v2">APK Signature Scheme v2</a></li> |
| 40 | <li><a href="#scoped_directory_access">Scoped Directory Access</a></li> |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 41 | <li><a href="#keyboard_shortcuts_helper">Keyboard Shortcuts Helper</a></li> |
Hemal Patel | 37663db | 2016-06-13 14:37:36 -0700 | [diff] [blame] | 42 | <li><a href="#custom_pointer_api">Custom Pointer API</a></li> |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 43 | <li><a href="#sustained_performance_api">Sustained Performance API</a></li> |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 44 | <li><a href="#vr">VR Support</a></li> |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 45 | <li><a href="#print_svc">Print Service Enhancements</a></li> |
Eric Schmidt | 186fada | 2016-04-27 11:48:22 -0700 | [diff] [blame] | 46 | <li><a href="#virtual_files">Virtual Files</a></li> |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 47 | <li><a href="#framemetrics_api">FrameMetricsListener API</a></li> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 48 | </ol> |
| 49 | </div> |
| 50 | </div> |
| 51 | |
| 52 | |
| 53 | |
| 54 | <p>Android N is still in active development, but you can try it |
| 55 | now as part of the N Developer Preview. The sections below highlight some of |
| 56 | the new features for developers. </p> |
| 57 | |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 58 | <p> |
| 59 | Make sure to check out the <a href= |
| 60 | "{@docRoot}preview/behavior-changes.html">Behavior Changes</a> to learn about |
| 61 | areas where platform changes may affect your apps, take a look at the |
| 62 | developer guides to learn more about key features, and download the <a href= |
| 63 | "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a> for details on |
| 64 | new APIs. |
| 65 | </p> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 66 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 67 | <h2 id="multi-window_support">Multi-window Support</h2> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 68 | |
| 69 | |
| 70 | <p>In Android N, we're introducing a new and much-requested multitasking feature |
| 71 | into the platform — multi-window support. </p> |
| 72 | |
| 73 | <p>Users can now pop open two apps on the screen at once. </p> |
| 74 | <ul> |
| 75 | <li>On phones and tablets |
| 76 | running Android N, users can run two apps side-by-side or |
| 77 | one-above-the-other in splitscreen mode. Users can resize the apps by dragging |
| 78 | the divider between them. </li> |
| 79 | |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 80 | <li>On Android TV devices, apps can put themselves in <a |
| 81 | href="{@docRoot}preview/features/picture-in-picture.html">picture-in-picture |
| 82 | mode</a>, allowing them to continue showing content while the user browses or |
Daniel Yu | 0ab19aa | 2016-03-14 15:35:38 -0700 | [diff] [blame] | 83 | interacts with other apps.</li> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 84 | </ul> |
| 85 | |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 86 | <div class="col-4of10"> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 87 | <img src="{@docRoot}preview/images/mw-portrait.png" alt="" style="height:460px;padding-left:1em;" |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 88 | id="img-split-screen" /> |
| 89 | <p class="img-caption"> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 90 | <strong>Figure 1.</strong> Apps running in split-screen mode. |
Dirk Dougherty | 5748bc4 | 2016-02-06 18:24:32 -0800 | [diff] [blame] | 91 | </p> |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 92 | |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 93 | </div> |
| 94 | |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 95 | <p>Especially on tablets and other larger-screen devices, multi-window support |
| 96 | gives you new ways to engage users. You can even enable drag-and-drop in |
| 97 | your app to let users conveniently drag content to or from your app — a great |
| 98 | way to enhance your user experience. </p> |
| 99 | |
| 100 | <p>It's straightforward to add multi-window support to your app and configure how it |
| 101 | handles multi-window display. For example, you can specify your activity's |
| 102 | minimum allowable dimensions, preventing users from resizing the activity below |
| 103 | that size. You can also disable multi-window display for your app, which |
| 104 | ensures that the system will only show your app in full-screen mode.</p> |
| 105 | |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 106 | <p> |
| 107 | For more information, see the <a href= |
| 108 | "{@docRoot}preview/features/multi-window.html">Multi-Window Support</a> |
| 109 | developer documentation. |
| 110 | </p> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 111 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 112 | <h2 id="notification_enhancements">Notification Enhancements</h2> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 113 | |
| 114 | <p>In Android N we've redesigned notifications to make them easier and faster to |
| 115 | use. Some of the changes include:</p> |
| 116 | |
| 117 | <ul> |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 118 | <li> |
| 119 | <strong>Template updates</strong>: We're updating notification templates to |
| 120 | put a new emphasis on hero image and avatar. Developers will be able to |
| 121 | take advantage of the new templates with minimal adjustments in their code. |
| 122 | </li> |
| 123 | |
| 124 | <li> |
Eric Schmidt | 8044822 | 2016-05-31 11:56:03 -0700 | [diff] [blame] | 125 | <strong>Messaging style customization</strong>: You can customize more of |
| 126 | the user interface labels associated with your notifications using the |
| 127 | <code>MessagingStyle</code> class. You can configure the message, |
| 128 | conversation title, and content view. |
Eric Schmidt | 57a83b5 | 2016-05-10 12:37:38 -0700 | [diff] [blame] | 129 | </li> |
| 130 | |
| 131 | <li> |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 132 | <strong>Bundled notifications</strong>: The system can group messages |
| 133 | together, for example by message topic, and display the group. A user can |
| 134 | take actions, such as Dismiss or Archive, on them in place. If you’ve |
| 135 | implemented notifications for Android Wear, you’ll already be familiar with |
Andrew Solovay | 069ac63 | 2016-03-11 11:23:27 -0800 | [diff] [blame] | 136 | this model. |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 137 | </li> |
| 138 | |
| 139 | <li> |
| 140 | <strong>Direct reply</strong>: For real-time communication apps, the |
| 141 | Android system supports inline replies so that users can quickly respond to |
| 142 | an SMS or text message directly within the notification interface. |
| 143 | </li> |
| 144 | |
| 145 | <li> |
| 146 | <strong>Custom views</strong>: Two new APIs enable you to leverage system |
| 147 | decorations, such as notification headers and actions, when using custom |
| 148 | views in notifications. |
| 149 | </li> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 150 | </ul> |
| 151 | |
| 152 | <div class="col-4of12"> |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 153 | <img src="{@docRoot}preview/images/notifications-1.png" alt="" |
| 154 | style="padding:.5em;max-width:226px"> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 155 | </div> |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 156 | |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 157 | <div class="col-4of12"> |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 158 | <img src="{@docRoot}preview/images/notifications-3.png" alt="" |
| 159 | style="padding:.5em;max-width:226px"> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 160 | </div> |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 161 | |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 162 | <div class="col-4of12"> |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 163 | <img src="{@docRoot}preview/images/notifications-2.png" alt="" |
| 164 | style="padding:.5em;max-width:226px"> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 165 | </div> |
| 166 | |
| 167 | |
| 168 | <p class="img-caption"> |
Adarsh Fernando | 3760156 | 2016-03-09 09:53:57 -0800 | [diff] [blame] | 169 | <strong>Figure 2.</strong> Bundled notifications and direct reply. |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 170 | </p> |
| 171 | |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 172 | <p>To learn how to implement the new features, see the |
| 173 | <a href="{@docRoot}preview/features/notification-updates.html">Notifications</a> |
| 174 | guide.</p> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 175 | |
| 176 | |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 177 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 178 | <h2 id="jit_aot">Profile-guided JIT/AOT Compilation</h2> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 179 | |
| 180 | <p>In Android N, we've added a Just in Time (JIT) compiler with code profiling to |
| 181 | ART, which lets it constantly improve the performance of Android apps as they |
| 182 | run. The JIT compiler complements ART's current Ahead of Time (AOT) compiler |
| 183 | and helps improve runtime performance, save storage space, and speed up app |
| 184 | updates and system updates.</p> |
| 185 | |
| 186 | <p>Profile-guided compilation lets ART manage the AOT/JIT compilation for each app |
| 187 | according to its actual usage, as well as conditions on the device. For |
| 188 | example, ART maintains a profile of each app's hot methods and can precompile |
| 189 | and cache those methods for best performance. It leaves other parts of the app |
| 190 | uncompiled until they are actually used.</p> |
| 191 | |
| 192 | <p>Besides improving performance for key parts of the app, profile-guided |
| 193 | compilation helps reduce an app's overall RAM footprint, including associated |
| 194 | binaries. This feature is especially important on low-memory devices.</p> |
| 195 | |
| 196 | <p>ART manages profile-guided compilation in a way that minimizes impact on the |
| 197 | device battery. It does precompilation only when then the device is idle and |
| 198 | charging, saving time and battery by doing that work in advance.</p> |
| 199 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 200 | <h2 id="quick_path_to_app_install">Quick Path to App Install</h2> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 201 | |
| 202 | <p>One of the most tangible benefits of ART's JIT compiler is the speed of app |
| 203 | installs and system updates. Even large apps that required several minutes to |
| 204 | optimize and install in Android 6.0 can now install in just a matter of |
| 205 | seconds. System updates are also faster, since there's no more optimizing step. </p> |
| 206 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 207 | <h2 id="doze_on_the_go">Doze on the Go...</h2> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 208 | |
| 209 | <p>Android 6.0 introduced Doze, a system mode that saves battery by deferring |
| 210 | apps' CPU and network activities when the device is idle, such as when it's |
| 211 | sitting on a table or in a drawer. </p> |
| 212 | |
| 213 | <p>Now in Android N, Doze takes a step further and saves battery while on the go. |
| 214 | Any time the screen is off for a period of time and the device is unplugged, |
| 215 | Doze applies a subset of the familiar CPU and network restrictions to apps. |
| 216 | This means users can save battery even when carrying their devices in their |
| 217 | pockets.</p> |
| 218 | |
| 219 | |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 220 | <img src="/preview/images/doze-diagram-1.png" |
| 221 | alt="" id="figure1" /> |
| 222 | <p class="img-caption"> |
Andrew Solovay | 069ac63 | 2016-03-11 11:23:27 -0800 | [diff] [blame] | 223 | <strong>Figure 3.</strong> Doze now applies |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 224 | restrictions to improve battery life even when the device is not stationary. |
| 225 | </p> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 226 | |
| 227 | |
| 228 | <p>A short time after the screen turns off while the device is on battery, Doze |
| 229 | restricts network access and defers jobs and syncs. During brief maintenance |
| 230 | windows, applications are allowed network access and any of their deferred |
| 231 | jobs/syncs are executed. Turning the screen on or plugging in the device brings |
| 232 | the device out of Doze.</p> |
| 233 | |
| 234 | <p>When the device is stationary again, with screen off and on battery for a |
| 235 | period of time, Doze applies the full CPU and network restrictions on {@link |
| 236 | android.os.PowerManager.WakeLock}, {@link android.app.AlarmManager} alarms, and |
| 237 | GPS/Wi-Fi scans.</p> |
| 238 | |
| 239 | <p>The best practices for adapting your app to Doze are the same whether the |
| 240 | device is moving or not, so if you already updated your app to gracefully |
| 241 | handle Doze, you're all set. If not, start <a |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 242 | href="{@docRoot}training/monitoring-device-state/doze-standby.html#assessing_your_app">adapting |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 243 | your app to Doze</a> now.</p> |
| 244 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 245 | <h2 id="background_optimizations">Project Svelte: Background Optimizations</h2> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 246 | |
| 247 | <p>Project Svelte is an ongoing effort to minimize RAM use by system and apps |
| 248 | across the range of Android devices in the ecosystem. In Android N, Project |
| 249 | Svelte is focused on optimizing the way apps run in the background. </p> |
| 250 | |
| 251 | <p>Background processing is an essential part of most apps. When handled right, it |
| 252 | can make your user experience amazing — immediate, fast, and context-aware. |
| 253 | When not handled right, background processing can needlessly consume RAM (and |
| 254 | battery) and affect system performance for other apps. </p> |
| 255 | |
Andrew Solovay | d6a6f96 | 2016-03-10 15:01:29 -0800 | [diff] [blame] | 256 | <p>Since Android 5.0, {@link android.app.job.JobScheduler} has been the |
| 257 | preferred way of performing background work in a way that's good |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 258 | for users. Apps can schedule jobs while letting the system optimize based on |
| 259 | memory, power, and connectivity conditions. JobScheduler offers control and |
| 260 | simplicity, and we want all apps to use it. </p> |
| 261 | |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 262 | <p> |
| 263 | Another good option is <a href= |
| 264 | "https://developers.google.com/android/reference/com/google/android/gms/gcm/GcmNetworkManager"> |
| 265 | <code>GCMNetworkManager</code></a>, part of Google Play Services, which |
| 266 | offers similar job scheduling with compatibility across legacy versions of |
| 267 | Android. |
| 268 | </p> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 269 | |
Andrew Solovay | d6a6f96 | 2016-03-10 15:01:29 -0800 | [diff] [blame] | 270 | <p>We're continuing to extend <code>JobScheduler</code> and |
| 271 | <code>GCMNetworkManager</code> to meet more of |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 272 | your use cases — for example, in Android N you can now schedule background |
| 273 | work based on changes in Content Providers. At the same time we're starting to |
| 274 | deprecate some of the older patterns that can reduce system performance, |
| 275 | especially on low-memory devices.</p> |
| 276 | |
| 277 | <p>In Android N we're removing three commonly-used implicit broadcasts — |
Adarsh Fernando | 3760156 | 2016-03-09 09:53:57 -0800 | [diff] [blame] | 278 | {@link android.net.ConnectivityManager#CONNECTIVITY_ACTION}, {@link |
| 279 | android.hardware.Camera#ACTION_NEW_PICTURE}, and {@link |
| 280 | android.hardware.Camera#ACTION_NEW_VIDEO} — since those can wake the |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 281 | background processes of multiple apps at once and strain memory and battery. If |
| 282 | your app is receiving these, take advantage of the N Developer Preview to |
| 283 | migrate to <code>JobScheduler</code> and related APIs instead. </p> |
| 284 | |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 285 | <p> |
| 286 | Take a look at the <a href= |
| 287 | "{@docRoot}preview/features/background-optimization.html">Background |
| 288 | Optimizations</a> documentation for details. |
| 289 | </p> |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 290 | |
David Friedman | 521da6a | 2016-06-14 15:37:16 -0700 | [diff] [blame] | 291 | <h2 id="surfaceview">SurfaceView</h2> |
| 292 | <p> |
| 293 | Android N brings synchronous movement to the {@link android.view.SurfaceView} |
| 294 | class, which provides better battery performance |
| 295 | than {@link android.view.TextureView} in certain cases: When rendering video or |
| 296 | 3D content, apps with scrolling and animated video position use less power with |
| 297 | {@link android.view.SurfaceView} than with {@link android.view.TextureView}. |
| 298 | </p> |
| 299 | |
| 300 | The {@link android.view.SurfaceView} class enables more battery-efficient compositing on |
| 301 | screen, because it is composited in dedicated hardware, separately from app |
| 302 | window content. As a result, it makes fewer intermediate |
| 303 | copies than {@link android.view.TextureView}. |
| 304 | </p> |
| 305 | |
| 306 | <p> |
| 307 | A {@link android.view.SurfaceView} object's content position is now updated synchronously |
| 308 | with the containing app content. One result of this change is that simple |
| 309 | translations or scales of a video playing in a {@link android.view.SurfaceView} |
| 310 | no longer produce black bars alongside the view as it moves. |
| 311 | </p> |
| 312 | |
| 313 | <p> |
| 314 | Starting with Android N, we strongly recommend that you save power by using |
| 315 | {@link android.view.SurfaceView} instead of {@link android.view.TextureView}. |
| 316 | </p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 317 | |
| 318 | <h2 id="data_saver">Data Saver</h2> |
| 319 | |
| 320 | <div class="col-5of12" style="margin-right:1.5em;"> |
| 321 | <img src="{@docRoot}preview/images/datasaver.png" style="border:2px solid #ddd"> |
| 322 | |
| 323 | <p class="img-caption" style="padding-right:2em;"> |
| 324 | <strong>Figure 4.</strong> Data Saver in Settings. |
| 325 | </p> |
| 326 | </div> |
| 327 | |
| 328 | <p>Over the life of a mobile device, the cost of a cellular data plan typically |
| 329 | exceeds the cost of the device itself. For many users, cellular data is an |
| 330 | expensive resource that they want to conserve. </p> |
| 331 | |
| 332 | <p>Android N introduces Data Saver mode, a new system service that helps reduce |
| 333 | cellular data use by apps, whether roaming, near the end of the billing cycle, |
| 334 | or on a small prepaid data pack. Data Saver gives users control over how apps |
| 335 | use cellular data and lets developers provide more efficient service when Data |
| 336 | Saver is on. </p> |
| 337 | |
| 338 | <p>When a user enables Data Saver in <strong>Settings</strong> and the device is |
| 339 | on a metered network, the system blocks background data usage and signals apps |
| 340 | to use less data in the foreground wherever possible — such as by limiting |
| 341 | bit rate for streaming, reducing image quality, deferring optimistic precaching, |
| 342 | and so on. Users can whitelist specific apps to allow background metered data |
| 343 | usage even when Data Saver is turned on.</p> |
| 344 | |
| 345 | <p>Android N extends the {@link android.net.ConnectivityManager} to provide apps a |
| 346 | way to <a href="{@docRoot}preview/features/data-saver.html#status">retrieve the |
| 347 | user's Data Saver preferences</a> and <a |
| 348 | href="{@docRoot}preview/features/data-saver.html#monitor-changes">monitor |
| 349 | preference changes</a>. All apps should check whether the user has enabled Data |
| 350 | Saver and make an effort to limit foreground and background data usage.</p> |
| 351 | |
| 352 | |
Andrew Solovay | 097b115 | 2016-04-06 17:33:00 -0700 | [diff] [blame] | 353 | <h2 id="vulkan">Vulkan API</h2> |
| 354 | |
| 355 | <p> |
| 356 | Android N integrates <a href="http://www.khronos.org/vulkan" class= |
| 357 | "external-link">Vulkan™</a>, a new 3D rendering API, into the platform. Like |
| 358 | <a href="https://www.khronos.org/opengles/" class="external-link">OpenGL™ |
| 359 | ES</a>, Vulkan is an open standard for 3D graphics and rendering maintained |
| 360 | by the Khronos Group. |
| 361 | </p> |
| 362 | |
| 363 | <p> |
| 364 | Vulkan is designed from the ground up to minimize CPU overhead in the driver, |
| 365 | and allow your application to control GPU operation more directly. Vulkan |
| 366 | also enables better parallelization by allowing multiple threads to perform |
| 367 | work such as command buffer construction at once. |
| 368 | </p> |
| 369 | |
| 370 | <p> |
| 371 | Vulkan development tools and libraries are rolled into the Android NDK. They |
| 372 | include: |
| 373 | </p> |
| 374 | |
| 375 | <ul> |
| 376 | <li>Headers |
| 377 | </li> |
| 378 | |
| 379 | <li>Validation layers (debug libraries) |
| 380 | </li> |
| 381 | |
| 382 | <li>SPIR-V shader compiler |
| 383 | </li> |
| 384 | |
| 385 | <li>SPIR-V runtime shader compilation library |
| 386 | </li> |
| 387 | </ul> |
| 388 | |
| 389 | <p> |
| 390 | Vulkan is only available to apps on devices with Vulkan-capable hardware, |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 391 | such as Nexus 5X, Nexus 6P, and Nexus Player. We're working closely with our |
Andrew Solovay | 097b115 | 2016-04-06 17:33:00 -0700 | [diff] [blame] | 392 | partners to bring Vulkan to more devices as soon as possible. |
| 393 | </p> |
| 394 | |
| 395 | <p> |
Andrew Solovay | f5266e5 | 2016-04-12 17:32:57 -0700 | [diff] [blame] | 396 | For more information, see the the <a href= |
| 397 | "{@docRoot}ndk/guides/graphics/index.html">API documentation</a>. |
Andrew Solovay | 097b115 | 2016-04-06 17:33:00 -0700 | [diff] [blame] | 398 | </p> |
| 399 | |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 400 | <h2 id="tile_api">Quick Settings Tile API</h2> |
| 401 | |
| 402 | |
| 403 | <div style="float:right;max-width:320px"> |
| 404 | <img src="{@docRoot}preview/images/quicksettings.png" style="padding-left:1.5em;"> |
| 405 | |
| 406 | <p class="img-caption" style="padding-left:2em;"> |
| 407 | <strong>Figure 5.</strong> Quick Settings tiles in the notification shade. |
| 408 | </p> |
| 409 | |
| 410 | |
| 411 | </div><p>Quick Settings is a popular and simple way to expose key settings and actions, |
| 412 | directly from the notification shade. In Android N, we've expanded the scope of |
| 413 | Quick Settings to make it even more useful and convenient. </p> |
| 414 | |
| 415 | <p>We've added more room for additional Quick Settings tiles, which users can |
| 416 | access across a paginated display area by swiping left or right. We've also |
| 417 | given users control over what Quick Settings tiles appear and where they are |
| 418 | displayed — users can add or move tiles just by dragging and dropping them. </p> |
| 419 | |
| 420 | <p>For developers, Android N also adds a new API that lets you define your own |
| 421 | Quick Settings tiles to give users easy access to key controls and actions in your app.</p> |
| 422 | |
| 423 | <p> |
| 424 | Quick Settings tiles are reserved for controls or actions that are either |
| 425 | urgently required or frequently used, and should not be used as shortcuts to |
| 426 | launching an app. |
| 427 | </p> |
| 428 | |
| 429 | <p> |
| 430 | Once you’ve defined your tiles, you can surface them to users, who can add |
| 431 | them to Quick Settings just by drag and drop. |
| 432 | </p> |
| 433 | |
| 434 | <p> |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 435 | For information about creating an app tile, see the documentation for |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 436 | <code>android.service.quicksettings.Tile</code> in the downloadable <a href= |
| 437 | "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>. |
| 438 | </p> |
| 439 | |
| 440 | |
| 441 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 442 | <h2 id="number-blocking">Number Blocking</h2> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 443 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 444 | <p>Android N now supports number blocking in the platform and provides a |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 445 | framework API to let service providers maintain a blocked-number list. The |
Andrew Solovay | ef93504 | 2016-03-14 14:25:36 -0700 | [diff] [blame] | 446 | default SMS app, the default phone app, and carrier apps can read from and |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 447 | write to the blocked-number list. The list is not accessible to other apps.</p> |
| 448 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 449 | <p>By making number blocking a standard feature of the platform, Android provides |
| 450 | a consistent way for apps to support number blocking across a wide range of |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 451 | devices. Among the other benefits that apps can take advantage of are:</p> |
| 452 | |
| 453 | <ul> |
| 454 | <li> Numbers blocked on calls are also blocked on texts |
| 455 | <li> Blocked numbers can persist across resets and devices through the Backup & |
| 456 | Restore feature |
| 457 | <li> Multiple apps can use the same blocked numbers list |
| 458 | </ul> |
| 459 | |
| 460 | <p>Additionally, carrier app integration through Android means that carriers can |
| 461 | read the blocked numbers list on the device and perform service-side blocking |
| 462 | for the user in order to stop unwanted calls and texts from reaching the user |
| 463 | through any medium, such as a VOIP endpoint or forwarding phones.</p> |
| 464 | |
| 465 | <p> |
| 466 | For more information, see <code>android.provider.BlockedNumberContract</code> |
| 467 | in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API |
| 468 | Reference</a>. |
| 469 | </p> |
| 470 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 471 | <h2 id="call_screening">Call Screening</h2> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 472 | |
| 473 | <p> |
| 474 | Android N allows the default phone app to screen incoming calls. The phone |
| 475 | app does this by implementing the new <code>CallScreeningService</code>, |
| 476 | which allows the phone app to perform a number of actions based on an |
| 477 | incoming call's {@link android.telecom.Call.Details Call.Details}, such as: |
| 478 | </p> |
| 479 | |
| 480 | <ul> |
| 481 | <li> Reject the incoming call |
| 482 | <li> Do not allow the call to the call log |
| 483 | <li> Do not show the user a notification for the call |
| 484 | </ul> |
| 485 | |
| 486 | <p> |
| 487 | For more information, see <code>android.telecom.CallScreeningService</code> |
| 488 | in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API |
| 489 | Reference</a>. |
| 490 | </p> |
| 491 | |
| 492 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 493 | <h2 id="multi-locale_languages">Multi-locale Support, More Languages</h2> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 494 | |
| 495 | |
| 496 | <p>Android N now lets users select <strong>multiple locales</strong> in Settings, |
| 497 | to better support bilingual use-cases. Apps can use |
| 498 | a new API to get the user's selected locales and then offer more sophisticated |
| 499 | user experiences for multi-locale users — such as showing search results in |
| 500 | multiple languages and not offering to translate webpages in a language the |
| 501 | user already knows.</p> |
| 502 | |
| 503 | <p>Along with multi-locale support, Android N also expands the range of languages |
| 504 | available to users. It offers more than 25 variants each for commonly used |
| 505 | languages such as English, Spanish, French, and Arabic. It also adds partial |
| 506 | support for more than 100 new languages.</p> |
| 507 | |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 508 | <p>Apps can get the list of locales set by the user by calling |
| 509 | <code>LocaleList.GetDefault()</code>. To support the expanded number of locales, Android N is |
| 510 | changing the way that it resolves resources. Make sure that you test and verify that your apps |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 511 | working as expected with the new resource resolution logic.</p> |
| 512 | |
| 513 | <p>To learn about the new resource-resolution behavior and the best practices you |
| 514 | should follow, see <a href="{@docRoot}preview/features/multilingual-support.html" |
| 515 | >Multilingual Support</a>.</p> |
| 516 | |
Eric Schmidt | 700127a | 2016-05-12 16:29:18 -0700 | [diff] [blame] | 517 | |
| 518 | <h2 id="emoji">New Emojis</h2> |
| 519 | |
| 520 | <p> |
| 521 | Android N introduces additional emojis and emoji-related features including |
| 522 | skin tone emojis and support for variation |
| 523 | selectors. If your app supports emojis, |
| 524 | follow the guidelines below to take advantage of these emoji-related features. |
| 525 | </p> |
| 526 | |
| 527 | <ul> |
| 528 | <li> |
| 529 | <strong>Check that a device contains an emoji before inserting it.</strong> |
| 530 | To check which emojis are present in the |
| 531 | system font, use the {@link android.graphics.Paint#hasGlyph(String)} method. |
| 532 | </li> |
| 533 | <li> |
| 534 | <strong>Check that an emoji supports variation selectors.</strong> |
| 535 | Variation selectors allow you to |
| 536 | present certain emojis in color or in black-and-white. |
| 537 | On mobile devices, apps should represent emojis in color rather than black-and-white. However, |
| 538 | if your app displays emojis inline with text, then it should use the black-and-white variation. |
| 539 | To determine whether an emoji has a variation, use the variation selector. |
| 540 | For a complete list of characters with variations, review the |
| 541 | <em>emoji variation sequences</em> section of the |
| 542 | <a class="external-link" |
| 543 | href="http://www.unicode.org/Public/9.0.0/ucd/StandardizedVariants-9.0.0d1.txt"> |
| 544 | Unicode documentation on variations</a>. |
| 545 | </li> |
| 546 | <li> |
| 547 | <strong>Check that an emoji supports skin tone.</strong> Android N allows users to modify the |
| 548 | rendered skin tone of emojis to their preference. Keyboard apps should provide visual |
| 549 | indications for emojis that have multiple skin tones and should allow users to |
| 550 | select the skin tone that they prefer. To determine which system emojis have |
| 551 | skin tone modifiers, use the {@link android.graphics.Paint#hasGlyph(String)} |
| 552 | method. You can determine which emojis use skin tones by reading the |
| 553 | <a class="external-link" |
| 554 | href="http://unicode.org/emoji/charts/full-emoji-list.html"> |
| 555 | Unicode documentation</a>. |
| 556 | </li> |
| 557 | </ul> |
| 558 | |
| 559 | |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 560 | <h2 id="icu4">ICU4J APIs in Android</h2> |
| 561 | |
| 562 | <p> |
| 563 | Android N now offers a subset of <a href= |
| 564 | "http://site.icu-project.org/">ICU4J</a> APIs in the Android framework under |
| 565 | the <code>android.icu</code> package. Migration is easy, and mostly entails |
| 566 | simply changing from the <code>com.java.icu</code> namespace to |
| 567 | <code>android.icu</code>. If you are already using an ICU4J bundle in your |
| 568 | apps, switching to the <code>android.icu</code> APIs provided in the Android |
| 569 | framework can produce substantial savings in APK size. |
| 570 | </p> |
| 571 | |
| 572 | <p> |
| 573 | To learn more about the Android ICU4J APIs, see <a href= |
| 574 | "{@docRoot}preview/features/icu4j-framework.html">ICU4J Support</a>. |
| 575 | </p> |
| 576 | |
Andrew Solovay | 1721c3e | 2016-07-15 13:04:04 -0700 | [diff] [blame] | 577 | <h2 id="webview">WebView</h2> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 578 | |
Andrew Solovay | 1721c3e | 2016-07-15 13:04:04 -0700 | [diff] [blame] | 579 | <h3>Chrome + WebView, Together</h3> |
| 580 | |
| 581 | <p> |
| 582 | Starting with Chrome version 51 on Android N and above, the Chrome APK on your device |
| 583 | is used to provide and render Android System WebViews. This approach improves memory |
| 584 | usage on the device itself and also reduces the bandwidth required to keep |
| 585 | WebView up to date (as the standalone WebView APK will no longer be updated |
| 586 | as long as Chrome remains enabled). |
| 587 | </p> |
| 588 | |
| 589 | <p> |
| 590 | You can choose your WebView provider by enabling Developer Options and |
| 591 | selecting <strong>WebView implementation</strong>. You can use any compatible |
| 592 | Chrome version (Dev, Beta or Stable) that is installed on your device or the |
| 593 | standalone Webview APK to act as the WebView implementation. |
| 594 | </p> |
| 595 | |
| 596 | <h3>Multiprocess</h3> |
| 597 | |
| 598 | <p> |
| 599 | Starting with Chrome version 51 in Android N, WebView will run web content in a |
| 600 | separate sandboxed process when the developer option "Multiprocess WebView" |
| 601 | is enabled. |
| 602 | </p> |
| 603 | |
| 604 | <p> |
| 605 | We're looking for feedback on compatibility and runtime performance in N |
| 606 | before enabling multiprocess WebView in a future version of Android. In this |
| 607 | version, regressions in startup time, total memory usage and software |
| 608 | rendering performance are expected. |
| 609 | </p> |
| 610 | |
| 611 | <p> |
| 612 | If you find unexpected issues in multiprocess mode we’d like to hear about |
| 613 | them. Please get in touch with the WebView team on the <a href= |
| 614 | "https://bugs.chromium.org/p/chromium/issues/entry?template=Webview%20Bugs" |
| 615 | >Chromium bug tracker</a>. |
| 616 | </p> |
| 617 | |
| 618 | <h3>Javascript run before page load</h3> |
| 619 | <p> |
| 620 | Starting with apps targeting Android N, the Javascript context will be reset |
| 621 | when a new page is loaded. Currently, the context is carried over for the |
| 622 | first page loaded in a new WebView instance. |
| 623 | </p> |
| 624 | |
| 625 | <p> |
| 626 | Developers looking to inject Javascript into the WebView should execute the |
| 627 | script after the page has started to load. |
| 628 | </p> |
| 629 | |
| 630 | <h3>Geolocation on insecure origins</h3> |
| 631 | |
| 632 | <p> |
| 633 | Starting with apps targeting Android N, the geolocation API will only be |
| 634 | allowed on secure origins (over HTTPS.) This policy is designed to protect |
| 635 | users’ private information when they’re using an insecure connection. |
| 636 | </p> |
| 637 | |
| 638 | <h3>Testing with WebView Beta</h3> |
| 639 | |
| 640 | <p> |
| 641 | WebView is updated regularly, so we recommend that you test compatibility |
| 642 | with your app frequently using WebView’s beta channel. To get started testing |
| 643 | pre-release versions of WebView on Android N, download and install either |
| 644 | Chrome Dev or Chrome Beta, and select it as the WebView implementation under |
| 645 | developer options as described above. Please report issues via the <a href= |
| 646 | "https://bugs.chromium.org/p/chromium/issues/entry?template=Webview%20Bugs">Chromium |
| 647 | bug tracker</a> so that we can fix them before a new version of WebView is |
| 648 | released. |
| 649 | </p> |
| 650 | |
| 651 | <p> |
| 652 | If you have any other questions or issues, feel free to reach out to the |
| 653 | WebView team via our <a href= |
| 654 | "https://plus.google.com/communities/105434725573080290360">G+ community</a>. |
| 655 | </p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 656 | |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 657 | <h2 id="gles_32">OpenGL™ ES 3.2 API</h2> |
| 658 | |
| 659 | <p>Android N adds framework interfaces and platform support for OpenGL ES 3.2, including:</p> |
| 660 | |
| 661 | <ul> |
| 662 | <li> All extensions from the <a class="external-link" |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 663 | href="https://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> |
| 664 | Android Extension Pack</a></a> (AEP) except for <code>EXT_texture_sRGB_decode</code>. |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 665 | <li> Floating-point framebuffers for HDR and deferred shading. |
| 666 | <li> BaseVertex draw calls to enable better batching and streaming. |
| 667 | <li> Robust buffer access control to reduce WebGL overhead. |
| 668 | </ul> |
| 669 | |
| 670 | <p>The framework API for OpenGL ES 3.2 on Android N is provided with the |
| 671 | <code>GLES32</code> class. When using OpenGL ES 3.2, be sure to declare the |
Andrew Solovay | 9b21857 | 2016-03-09 11:17:07 -0800 | [diff] [blame] | 672 | requirement in your manifest file, using the <code><uses-feature></code> tag and |
Dirk Dougherty | cf65e484 | 2016-03-07 22:31:57 -0800 | [diff] [blame] | 673 | the <code>android:glEsVersion</code> attribute. </p> |
| 674 | |
| 675 | <p>For information about using OpenGL ES, including how to check a device's |
| 676 | supported OpenGL ES version at runtime, see the <a |
| 677 | href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL ES API guide</a>.</p> |
| 678 | |
| 679 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 680 | <h2 id="android_tv_recording">Android TV Recording</h2> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 681 | |
| 682 | <p>Android N adds the ability to record and playback content from Android TV input |
| 683 | services via new recording APIs. Building on top of existing time-shifting |
| 684 | APIs, TV input services can control what channel data can be recorded, how |
| 685 | recorded sessions are saved, and manage user interaction with recorded content. </p> |
| 686 | |
| 687 | <p>For more information, see <a |
| 688 | href="{@docRoot}preview/features/tv-recording-api.html">Android TV Recording APIs</a>.</p> |
| 689 | |
| 690 | |
| 691 | <h2 id="android_for_work">Android for Work</h2> |
| 692 | |
| 693 | <p>Android for Work adds many new features and APIs for devices running Android N. |
Kevin Hufnagle | b6d1723 | 2016-03-22 11:29:03 -0700 | [diff] [blame] | 694 | Some highlights are below — for a complete list of changes, see |
| 695 | <a href="{@docRoot}preview/features/afw.html">Android for Work Updates</a>.</p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 696 | |
| 697 | <h3 id="work_profile_security_challenge">Work profile security challenge </h3> |
| 698 | |
| 699 | <p> |
Andrew Solovay | 097b115 | 2016-04-06 17:33:00 -0700 | [diff] [blame] | 700 | Profile owners targeting the N SDK |
| 701 | can specify a separate security challenge for apps running in |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 702 | the work profile. The work challenge is shown when a user attempts to open |
| 703 | any work apps. Successful completion of the security challenge unlocks the |
| 704 | work profile and decrypts it if necessary. For profile owners, |
| 705 | <code>ACTION_SET_NEW_PASSWORD</code> prompts the user to set a work |
| 706 | challenge, and <code>ACTION_SET_NEW_PARENT_PROFILE_PASSWORD</code> prompts |
| 707 | the user to set a device lock. |
| 708 | </p> |
| 709 | |
| 710 | <p> |
Andrew Solovay | 097b115 | 2016-04-06 17:33:00 -0700 | [diff] [blame] | 711 | Profile owners can set distinct passcode policies for the work challenge |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 712 | (such as how long the PIN needs to be, or whether a fingerprint can be used |
| 713 | to unlock the profile) using the <code>setPasswordQuality()</code>, |
| 714 | <code>setPasswordMinimumLength()</code> and related methods. The profile |
| 715 | owner can also set the device lock using the <code>DevicePolicyManager</code> |
| 716 | instance returned by the new <code>getParentProfileInstance()</code> method. |
| 717 | Additionally, profile owners can customize the credentials screen for the |
| 718 | work challenge using the new <code>setOrganizationColor()</code> and |
| 719 | <code>setOrganizationName()</code> methods. |
| 720 | </p> |
| 721 | <h3 id="turn_off_work">Turn off work </h3> |
| 722 | |
| 723 | <p>On a device with a work profile, users can toggle work mode. When work mode is |
| 724 | off the managed user is temporarily shut down, which disables work profile |
| 725 | apps, background sync, and notifications. This includes the profile owner |
| 726 | application. When work mode is off, the system displays a persistent status |
| 727 | icon to remind the user that they can't launch work apps. The launcher |
| 728 | indicates that work apps and widgets are not accessible. </p> |
| 729 | |
| 730 | <h3 id="always_on_vpn">Always on VPN </h3> |
| 731 | |
| 732 | <p>Device owners and profile owners can ensure that work apps always connect |
| 733 | through a specified VPN. The system automatically starts that VPN after the |
| 734 | device boots.</p> |
| 735 | |
| 736 | <p> |
| 737 | New <code>DevicePolicyManager</code> methods are |
| 738 | <code>setAlwaysOnVpnPackage()</code> and |
| 739 | <code>getAlwaysOnVpnPackage()</code>. |
| 740 | </p> |
| 741 | |
| 742 | <p>Because VPN services can be bound directly by the system without app |
| 743 | interaction, VPN clients need to handle new entry points for Always on VPN. As |
| 744 | before, services are indicated to the system by an intent filter matching |
| 745 | action <code>android.net.VpnService</code>. </p> |
| 746 | |
| 747 | <p> |
| 748 | Users can also manually set Always on VPN clients that implement |
Andrew Solovay | 1721c3e | 2016-07-15 13:04:04 -0700 | [diff] [blame] | 749 | <code>VPNService</code> methods using |
| 750 | <strong>Settings>More>Vpn</strong>. The option to enable Always on VPN |
| 751 | from Settings is available only if VPN client targets API level 24. |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 752 | </p> |
| 753 | |
Andrew Solovay | 097b115 | 2016-04-06 17:33:00 -0700 | [diff] [blame] | 754 | <h3 id="custom_provisioning">Customized provisioning</h3> |
| 755 | |
| 756 | <p> |
| 757 | An application can customize the profile owner and device owner provisioning |
| 758 | flows with corporate colors and logos. |
| 759 | <code>DevicePolicyManager.EXTRA_PROVISIONING_MAIN_COLOR</code> customizes |
| 760 | flow color. <code>DevicePolicyManager.EXTRA_PROVISIONING_LOGO_URI</code> |
| 761 | customizes the flow with a corporate logo. |
| 762 | </p> |
| 763 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 764 | <h2 id="accessibility_enhancements">Accessibility Enhancements</h2> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 765 | |
| 766 | <p>Android N now offers Vision Settings directly on the Welcome screen for new |
| 767 | device setup. This makes it much easier for users to discover and configure |
| 768 | accessibility features on their devices, including magnification gesture, font |
| 769 | size, display size, and TalkBack. </p> |
| 770 | |
| 771 | <p>With these accessibility features getting more prominent placement, your users |
| 772 | are more likely to try your app with them enabled. Make sure you test your apps |
| 773 | early with these settings enabled. You can enable them from Settings > |
| 774 | Accessibility.</p> |
| 775 | |
| 776 | <p>Also in Android N, accessibility services can now help users with motor |
| 777 | impairments to touch the screen. The new API allows building services with |
| 778 | features such as face-tracking, eye-tracking, point scanning, and so on, to |
| 779 | meet the needs of those users.</p> |
| 780 | |
| 781 | <p>For more information, see <code>android.accessibilityservice.GestureDescription</code> |
Eric Schmidt | 57a83b5 | 2016-05-10 12:37:38 -0700 | [diff] [blame] | 782 | in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.</p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 783 | |
| 784 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 785 | <h2 id="direct_boot">Direct Boot</h2> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 786 | |
| 787 | <p>Direct boot improves device startup times and lets registered |
| 788 | apps have limited functionality even after an unexpected reboot. |
| 789 | For example, if an encrypted device reboots while the user is sleeping, |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 790 | registered alarms, messages and incoming calls can now continue to notify |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 791 | the user as normal. This also means accessibility services can also be |
| 792 | available immediately after a restart.</p> |
| 793 | |
| 794 | <p>Direct boot takes advantage of file based encryption in Android N |
| 795 | to enable fine grained encryption policies for both system and app data. |
| 796 | The system uses a device-encrypted store for select system data and explicitly |
| 797 | registered app data. By default a credential-encrypted store is used for all |
| 798 | other system data, user data, apps, and app data. </p> |
| 799 | |
| 800 | <p>At boot, the system starts in a restricted mode with access to |
| 801 | device-encrypted data only, and without general access to apps or data. |
| 802 | If you have components that you want to run in this mode, you can register |
| 803 | them by setting a flag in the manifest. After restart, the system activates |
| 804 | registered components by broadcasting the <code>LOCKED_BOOT_COMPLETED</code> |
| 805 | intent. The system ensures registered device-encrypted app data is available |
| 806 | before unlock. All other data is unavailable until the User confirms their lock |
| 807 | screen credentials to decrypt it. </p> |
| 808 | |
| 809 | For more information, see <a href="{@docRoot}preview/features/direct-boot.html">Direct Boot</a>.</p> |
| 810 | </p> |
| 811 | |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 812 | <h2 id="key_attestation">Key Attestation</h2> |
| 813 | |
Kevin Hufnagle | 23239ca | 2016-06-09 16:02:31 -0700 | [diff] [blame] | 814 | <p> |
| 815 | Android N introduces <em>key attestation</em>, a new security tool that helps |
| 816 | you make sure that the key pairs stored within a device's <a class= |
| 817 | "external-link" href= |
| 818 | "https://source.android.com/security/keystore/"><em>hardware-backed |
| 819 | keystore</em></a> properly protect the sensitive information that your app |
| 820 | uses. By using this tool, you gain additional confidence that your app |
| 821 | interacts with keys that reside in secure hardware, even if the device |
| 822 | running your app is rooted. If you use keys from the hardware-backed keystore |
| 823 | in your apps, you should use this tool, particularly if you use the keys to |
| 824 | verify sensitive information within your app. |
| 825 | </p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 826 | |
Kevin Hufnagle | 23239ca | 2016-06-09 16:02:31 -0700 | [diff] [blame] | 827 | <p> |
| 828 | Key attestation allows you to verify that an RSA or EC key pair has been |
| 829 | created and stored in a device’s hardware-backed keystore within the device’s |
| 830 | trusted execution environment (TEE). The tool also allows you to use an |
| 831 | off-device service, such as your app's back-end server, to determine and |
| 832 | strongly verify the uses and validity of the key pair. These features provide |
| 833 | an additional level of security that protects the key pair, even if someone |
| 834 | roots the device or compromises the security of the Android platform running |
| 835 | on the device. |
| 836 | </p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 837 | |
Kevin Hufnagle | 0da25a6 | 2016-07-14 12:32:52 -0700 | [diff] [blame] | 838 | <p class="note"> |
| 839 | <strong>Note: </strong>Only a small number of devices running Android N |
| 840 | support hardware-level key attestation; all other devices running Android N |
| 841 | use software-level key attestation instead. Before you verify the properties |
| 842 | of a device's hardware-backed keys in a production-level environment, you |
| 843 | should make sure that the device supports hardware-level key attestation. To |
| 844 | do so, you should check that the attestation certificate chain contains a root |
| 845 | certificate that is signed by the Google attestation root key and that the |
| 846 | <code>attestationSecurityLevel</code> element within the <a |
| 847 | href="{@docRoot}preview/features/key-attestation.html#certificate_schema_keydescription">key |
| 848 | description</a> data structure is set to the TrustedEnvironment security |
| 849 | level. |
| 850 | </p> |
| 851 | |
Kevin Hufnagle | 23239ca | 2016-06-09 16:02:31 -0700 | [diff] [blame] | 852 | <p> |
| 853 | For more information, see the |
| 854 | <a href="{@docRoot}preview/features/key-attestation.html">Key Attestation</a> |
| 855 | developer documentation. |
| 856 | </p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 857 | |
| 858 | <h2 id="network_security_config">Network Security Config</h2> |
| 859 | |
| 860 | <p>In Android N, apps can customize the behavior of their secure (HTTPS, TLS) |
| 861 | connections safely, without any code modification, by using the declarative |
| 862 | <em>Network Security Config</em> instead of using the conventional |
| 863 | error-prone programmatic APIs (e.g. X509TrustManager).</p> |
| 864 | |
| 865 | <p>Supported features:</p> |
| 866 | <ul> |
| 867 | <li><b>Custom trust anchors.</b> Lets an application customize which |
| 868 | Certificate Authorities (CA) are trusted for its secure connections. For |
| 869 | example, trusting particular self-signed certificates or a restricted set of public CAs. |
| 870 | </li> |
| 871 | <li><b>Debug-only overrides.</b> Lets an application developer safely debug |
| 872 | secure connections of their application without added risk to the installed |
| 873 | base. |
| 874 | </li> |
| 875 | <li><b>Cleartext traffic opt-out.</b> Lets an application protect itself from |
| 876 | accidental usage of cleartext traffic.</li> |
| 877 | <li><b>Certificate pinning.</b> An advanced feature that lets an application |
| 878 | limit which server keys are trusted for secure connections.</li> |
| 879 | </ul> |
| 880 | |
| 881 | <p>For more information, see <a |
| 882 | href="{@docRoot}preview/features/security-config.html">Network Security |
| 883 | Config</a>.</p> |
| 884 | |
| 885 | <h2 id="default_trusted_ca">Default Trusted Certificate Authority</h2> |
| 886 | |
| 887 | <p>By default, apps that target Android N only trust system-provided certificates |
| 888 | and no longer trust user-added Certificate Authorities (CA). Apps targeting Android |
| 889 | N that wish to trust user-added CAs should use the |
| 890 | <a href="{@docRoot}preview/features/security-config.html">Network Security Config</a> to |
| 891 | specify how user CAs should be trusted.</p> |
| 892 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 893 | <h2 id="apk_signature_v2">APK Signature Scheme v2</h2> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 894 | |
Kevin Hufnagle | 7cd4a10 | 2016-05-04 15:30:45 -0700 | [diff] [blame] | 895 | <p> |
| 896 | Android N introduces APK Signature Scheme v2, a new app-signing scheme that |
Kevin Hufnagle | aa1b7dd | 2016-05-11 17:38:45 -0700 | [diff] [blame] | 897 | offers faster app install times and more protection against unauthorized |
| 898 | alterations to APK files. By default, Android Studio 2.2 and the Android |
| 899 | Plugin for Gradle 2.2 sign your app using both APK Signature Scheme v2 and |
| 900 | the traditional signing scheme, which uses JAR signing. |
Kevin Hufnagle | 7cd4a10 | 2016-05-04 15:30:45 -0700 | [diff] [blame] | 901 | </p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 902 | |
Kevin Hufnagle | 7cd4a10 | 2016-05-04 15:30:45 -0700 | [diff] [blame] | 903 | <p> |
Kevin Hufnagle | aa1b7dd | 2016-05-11 17:38:45 -0700 | [diff] [blame] | 904 | Although we recommend applying APK Signature Scheme v2 to your app, this new |
| 905 | scheme is not mandatory. If your app doesn't build properly when using APK |
| 906 | Signature Scheme v2, you can disable the new scheme. The disabling process |
| 907 | causes Android Studio 2.2 and the Android Plugin for Gradle 2.2 to sign your |
| 908 | app using only the traditional signing scheme. To sign with only the |
| 909 | traditional scheme, open the module-level <code>build.gradle</code> file, then |
| 910 | add the line <code>v2SigningEnabled false</code> to your release signing |
| 911 | configuration: |
Kevin Hufnagle | 7cd4a10 | 2016-05-04 15:30:45 -0700 | [diff] [blame] | 912 | </p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 913 | |
Kevin Hufnagle | 7cd4a10 | 2016-05-04 15:30:45 -0700 | [diff] [blame] | 914 | <pre> |
| 915 | android { |
| 916 | ... |
| 917 | defaultConfig { ... } |
| 918 | signingConfigs { |
| 919 | release { |
| 920 | storeFile file("myreleasekey.keystore") |
| 921 | storePassword "password" |
| 922 | keyAlias "MyReleaseKey" |
| 923 | keyPassword "password" |
| 924 | <strong>v2SigningEnabled false</strong> |
| 925 | } |
| 926 | } |
| 927 | } |
| 928 | </pre> |
| 929 | |
Kevin Hufnagle | aa1b7dd | 2016-05-11 17:38:45 -0700 | [diff] [blame] | 930 | <p class="caution"><strong>Caution: </strong> If you sign your app using APK |
| 931 | Signature Scheme v2 and make further changes to the app, the app's signature |
| 932 | is invalidated. For this reason, use tools such as <code>zipalign</code> |
| 933 | before signing your app using APK Signature Scheme v2, not after. |
| 934 | </p> |
| 935 | |
Kevin Hufnagle | 7cd4a10 | 2016-05-04 15:30:45 -0700 | [diff] [blame] | 936 | <p> |
Kevin Hufnagle | aa1b7dd | 2016-05-11 17:38:45 -0700 | [diff] [blame] | 937 | For more information, read the Android Studio documents that describe how to |
smain@google.com | 73cf822 | 2016-05-19 16:30:43 -0700 | [diff] [blame] | 938 | <a href="{@docRoot}studio/publish/app-signing.html#release-mode"> |
Kevin Hufnagle | aa1b7dd | 2016-05-11 17:38:45 -0700 | [diff] [blame] | 939 | sign an app</a> in Android Studio and how to <a href= |
smain@google.com | 73cf822 | 2016-05-19 16:30:43 -0700 | [diff] [blame] | 940 | "{@docRoot}studio/build/build-variants.html#signing"> configure |
Kevin Hufnagle | aa1b7dd | 2016-05-11 17:38:45 -0700 | [diff] [blame] | 941 | the build file for signing apps</a> using the Android Plugin for Gradle. |
Kevin Hufnagle | 7cd4a10 | 2016-05-04 15:30:45 -0700 | [diff] [blame] | 942 | </p> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 943 | |
David Friedman | 82c668f | 2016-05-17 23:53:21 -0700 | [diff] [blame] | 944 | <h2 id="scoped_directory_access">Scoped Directory Access</h2> |
Dirk Dougherty | 5942892 | 2016-03-10 18:54:49 -0800 | [diff] [blame] | 945 | |
| 946 | <p>In Android N, apps can use new APIs to request access to specific <a |
| 947 | href="{@docRoot}guide/topics/data/data-storage.html#filesExternal">external |
| 948 | storage</a> directories, including directories on removable media such as SD |
| 949 | cards. The new APIs greatly simplify how your application accesses standard |
| 950 | external storage directories, such as the <code>Pictures</code> directory. Apps |
| 951 | like photo apps can use these APIs instead of using |
| 952 | <code>READ_EXTERNAL_STORAGE</code>, which grants access to all storage |
| 953 | directories, or the Storage Access Framework, which makes the user navigate to |
| 954 | the directory.</p> |
| 955 | |
| 956 | <p>Additionally, the new APIs simplify the steps a user takes to grant external |
| 957 | storage access to your app. When you use the new APIs, the system uses a simple |
| 958 | permissions UI that clearly details what directory the application is |
| 959 | requesting access to.</p> |
| 960 | |
| 961 | <p>For more information, see the |
| 962 | <a href="{@docRoot}preview/features/scoped-folder-access.html">Scoped |
| 963 | Directory Access</a> developer documentation.</p> |
| 964 | |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 965 | <h2 id="keyboard_shortcuts_helper">Keyboard Shortcuts Helper</h2> |
| 966 | |
| 967 | <p> |
Hemal Patel | dd4a8e7 | 2016-06-07 18:22:21 -0700 | [diff] [blame] | 968 | In Android N, the user can press <strong>Meta + /</strong> to trigger a |
| 969 | <em>Keyboard Shortcuts</em> screen that displays all shortcuts available both |
| 970 | from the system and from the app in focus. The system retrieves these |
| 971 | shortcuts automatically from the app’s menu if the shortcuts exist. You can |
| 972 | also provide your own fine-tuned shortcuts lists for the screen. You can do |
| 973 | this by overriding the new <code>Activity.onProvideKeyboardShortcuts()</code> |
| 974 | method, described in the downloadable <a href= |
| 975 | "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>. |
| 976 | </p> |
| 977 | |
| 978 | <p class="note"> |
| 979 | <strong>Note:</strong> The <strong>Meta</strong> key is not present on all |
| 980 | keyboards: on a Macintosh keyboard, it is the <strong>Command</strong> key, |
| 981 | on the Windows keyboard, it is the <strong>Windows</strong> key, and on the |
| 982 | Pixel C and the Chrome OS keyboards, it is the <strong>Search</strong> key. |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 983 | </p> |
| 984 | |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 985 | <p> |
Hemal Patel | dd4a8e7 | 2016-06-07 18:22:21 -0700 | [diff] [blame] | 986 | To trigger Keyboard Shortcuts Helper from anywhere in your app, call |
| 987 | {@code Activity.requestKeyboardShortcutsHelper()} for the relevant activity. |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 988 | </p> |
| 989 | |
Hemal Patel | 37663db | 2016-06-13 14:37:36 -0700 | [diff] [blame] | 990 | <h2 id="custom_pointer_api"> |
| 991 | Custom Pointer API |
| 992 | </h2> |
| 993 | |
| 994 | <p> |
| 995 | Android N introduces the Custom Pointer API, which lets you customize the |
| 996 | appearance, visibility, and behavior of the pointer. This capability is |
| 997 | especially useful when a user is using a mouse or touchpad to interact with |
| 998 | UI objects. The default pointer uses a standard icon. This API also includes |
| 999 | advanced functionality such as changing the pointer icon's appearance based |
| 1000 | on specific mouse or touchpad movements. |
| 1001 | </p> |
| 1002 | |
| 1003 | <p> |
| 1004 | To set a pointer icon, override the <code>onResolvePointerIcon()</code> |
| 1005 | method of the <code>View</code> class. This method uses a |
| 1006 | <code>PointerIcon</code> object to draw the icon that corresponds to a |
| 1007 | specific motion event. |
| 1008 | </p> |
| 1009 | |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1010 | <h2 id="sustained_performance_api">Sustained Performance API</h2> |
| 1011 | |
| 1012 | <p> |
| 1013 | Performance can fluctuate dramatically for long-running apps, because the |
| 1014 | system throttles system-on-chip engines as device components reach their |
| 1015 | temperature limits. This fluctuation presents a moving target for app |
| 1016 | developers creating high-performance, long-running apps. |
| 1017 | </p> |
| 1018 | |
| 1019 | <p> |
| 1020 | To address these limitations, Android N includes support for |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 1021 | <em>sustained performance mode</em>, enabling OEMs to provide hints about |
| 1022 | device-performance capabilities for long-running apps. App developers |
| 1023 | can use these hints to tune apps for a predictable, |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1024 | consistent level of device performance over long periods of time. |
| 1025 | </p> |
| 1026 | |
| 1027 | <p> |
| 1028 | App developers can try out this new API in the N Developer Preview on |
| 1029 | Nexus 6P devices only. To use this feature, |
| 1030 | set the sustained performance window flag for the window |
| 1031 | you want to run in sustained performance mode. Set this flag using the |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 1032 | {@code Window.setSustainedPerformanceMode()} method. The system automatically |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1033 | disables this mode when the window is no longer in focus. |
| 1034 | </p> |
| 1035 | |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 1036 | <h2 id="vr">VR Support</h2> |
| 1037 | |
| 1038 | <p> |
David Friedman | 2023739 | 2016-05-17 15:31:25 -0700 | [diff] [blame] | 1039 | Android N adds platform support and optimizations for a new VR Mode to let developers |
| 1040 | build high-quality mobile VR experiences for users. There are a number of performance |
| 1041 | enhancements, including access to an exclusive CPU core for VR apps. |
| 1042 | Within your apps, you can take advantage of intelligent head-tracking, |
| 1043 | and stereo notifications that work for VR. Most importantly, Android N provides for |
| 1044 | very low latency graphics. For complete information about building VR apps for Android N, |
| 1045 | see the <a href="https://developers.google.com/vr/android/">Google VR SDK for Android</a>. |
| 1046 | </p> |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 1047 | |
| 1048 | |
Andrew Solovay | 097b115 | 2016-04-06 17:33:00 -0700 | [diff] [blame] | 1049 | <h2 id="print_svc">Print Service Enhancements</h2> |
| 1050 | |
| 1051 | <p> |
| 1052 | In Android N, print service developers can now surface additional information |
| 1053 | about individual printers and print jobs. |
| 1054 | </p> |
| 1055 | |
| 1056 | <p> |
| 1057 | When listing individual printers, a print service can now set per-printer |
| 1058 | icons in two ways: |
| 1059 | </p> |
| 1060 | |
| 1061 | <ul> |
| 1062 | <li>You can set an icon from a resource ID by calling |
| 1063 | <code>PrinterInfo.Builder.setResourceIconId()</code> |
| 1064 | </li> |
| 1065 | |
| 1066 | <li>You can show an icon from the network by calling |
| 1067 | <code>PrinterInfo.Builder.setHasCustomPrinterIcon()</code>, and setting a |
| 1068 | callback for when the icon is requested using |
| 1069 | <code>android.printservice.PrinterDiscoverySession.onRequestCustomPrinterIcon()</code> |
| 1070 | </li> |
| 1071 | </ul> |
| 1072 | |
| 1073 | <p> |
| 1074 | In addition, you can provide a per-printer activity to display additional |
| 1075 | information by calling <code>PrinterInfo.Builder.setInfoIntent()</code>. |
| 1076 | </p> |
| 1077 | |
| 1078 | <p> |
| 1079 | You can indicate the progress and status of print jobs in the print job |
| 1080 | notification by calling |
| 1081 | <code>android.printservice.PrintJob.setProgress()</code> and |
| 1082 | <code>android.printservice.PrintJob.setStatus()</code>, respectively. |
| 1083 | </p> |
| 1084 | |
| 1085 | <p> |
| 1086 | For more information about these methods, see the downloadable <a href= |
| 1087 | "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>. |
| 1088 | </p> |
Eric Schmidt | 186fada | 2016-04-27 11:48:22 -0700 | [diff] [blame] | 1089 | |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1090 | <h2 id="framemetrics_api">FrameMetricsListener API</h2> |
| 1091 | |
| 1092 | <p> |
| 1093 | The FrameMetricsListener API allows an app to monitor its UI rendering |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 1094 | performance. The API provides this capability by exposing a streaming Pub/Sub API to transfer frame |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1095 | timing info for the app's current window. The data returned is |
David Friedman | 2023739 | 2016-05-17 15:31:25 -0700 | [diff] [blame] | 1096 | equivalent to that which <code><a href="{@docRoot}tools/help/shell.html#shellcommands">adb shell</a> |
| 1097 | dumpsys gfxinfo framestats</code> displays, but is not limited to the past 120 frames. |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1098 | </p> |
| 1099 | |
| 1100 | <p> |
| 1101 | You can use FrameMetricsListener to measure interaction-level UI |
| 1102 | performance in production, without a USB connection. This API |
| 1103 | allows collection of data at a much higher granularity than does |
| 1104 | {@code adb shell dumpsys gfxinfo}. This higher granularity is possible because |
| 1105 | the system can collect data for particular interactions in the app; the system |
| 1106 | need not capture a global summary of the entire app’s |
| 1107 | performance, or clear any global state. You can use this |
| 1108 | capability to gather performance data and catch regressions in UI performance |
| 1109 | for real use cases within an app. |
| 1110 | </p> |
| 1111 | |
| 1112 | <p> |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 1113 | To monitor a window, implement the <code>FrameMetricsListener.onMetricsAvailable()</code> |
| 1114 | callback method and register it on that window. For more information, refer to |
| 1115 | the {@code FrameMetricsListener} class documentation in |
| 1116 | the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>. |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1117 | </p> |
| 1118 | |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1119 | <p> |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 1120 | The API provides a {@code FrameMetrics} object, which contains timing data that |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1121 | the rendering subsystem reports for various milestones in a frame lifecycle. |
| 1122 | The supported metrics are: {@code UNKNOWN_DELAY_DURATION}, |
| 1123 | {@code INPUT_HANDLING_DURATION}, {@code ANIMATION_DURATION}, |
| 1124 | {@code LAYOUT_MEASURE_DURATION}, {@code DRAW_DURATION}, {@code SYNC_DURATION}, |
| 1125 | {@code COMMAND_ISSUE_DURATION}, {@code SWAP_BUFFERS_DURATION}, |
David Friedman | 182e8b5 | 2016-05-13 10:03:52 -0700 | [diff] [blame] | 1126 | {@code TOTAL_DURATION}, and {@code FIRST_DRAW_FRAME}. |
David Friedman | 93970ba | 2016-05-13 01:23:13 -0700 | [diff] [blame] | 1127 | </p> |
| 1128 | |
| 1129 | |
Eric Schmidt | 186fada | 2016-04-27 11:48:22 -0700 | [diff] [blame] | 1130 | <h2 id="virtual_files">Virtual Files</h2> |
| 1131 | |
| 1132 | <p> |
| 1133 | In previous versions of Android, your app could use the Storage Access |
| 1134 | Framework to allow users to select files from their cloud storage accounts, |
| 1135 | such as Google Drive. However, there was no way to represent files that did |
| 1136 | not have a direct bytecode representation; every file was required to provide |
| 1137 | an input stream. |
| 1138 | </p> |
| 1139 | |
| 1140 | <p> |
| 1141 | Android N adds the concept of <em>virtual files</em> to the Storage Access |
| 1142 | Framework. The virtual files feature allows your |
| 1143 | {@link android.provider.DocumentsProvider} to return document URIs that can be |
| 1144 | used with an {@link android.content.Intent#ACTION_VIEW} intent even if they |
| 1145 | don't have a direct bytecode representation. Android N also allows you to |
| 1146 | provide alternate formats for user files, virtual or otherwise. |
| 1147 | </p> |
| 1148 | |
| 1149 | <p> |
| 1150 | To get a URI for a virtual document in your app, first you create an |
| 1151 | {@link android.content.Intent} to open the file picker UI. Since an app |
| 1152 | cannot directly open a virtual file by using the |
| 1153 | {@link android.content.ContentResolver#openInputStream(Uri) openInputStream()} |
| 1154 | method, your app does not receive any virtual files if you include the |
| 1155 | {@link android.content.Intent#CATEGORY_OPENABLE} category. |
| 1156 | </p> |
| 1157 | |
| 1158 | <p> |
| 1159 | After the user has made a selection, the system calls the |
| 1160 | {@link android.app.Activity#onActivityResult onActivityResult()} method. |
| 1161 | Your app can retrieve the URI of the virtual file and get an input stream, as |
| 1162 | demonstrated in the code snippet below. |
| 1163 | </p> |
| 1164 | |
| 1165 | <pre> |
| 1166 | // Other Activity code ... |
| 1167 | |
| 1168 | final static private int REQUEST_CODE = 64; |
| 1169 | |
| 1170 | // We listen to the OnActivityResult event to respond to the user's selection. |
| 1171 | @Override |
| 1172 | public void onActivityResult(int requestCode, int resultCode, |
| 1173 | Intent resultData) { |
| 1174 | try { |
| 1175 | if (requestCode == REQUEST_CODE && |
| 1176 | resultCode == Activity.RESULT_OK) { |
| 1177 | |
| 1178 | Uri uri = null; |
| 1179 | |
| 1180 | if (resultData != null) { |
| 1181 | uri = resultData.getData(); |
| 1182 | |
| 1183 | ContentResolver resolver = getContentResolver(); |
| 1184 | |
| 1185 | // Before attempting to coerce a file into a MIME type, |
| 1186 | // check to see what alternative MIME types are available to |
| 1187 | // coerce this file into. |
| 1188 | String[] streamTypes = |
| 1189 | resolver.getStreamTypes(uri, "*/*"); |
| 1190 | |
| 1191 | AssetFileDescriptor descriptor = |
| 1192 | resolver.openTypedAssetFileDescriptor( |
| 1193 | uri, |
| 1194 | streamTypes[0], |
| 1195 | null); |
| 1196 | |
| 1197 | // Retrieve a stream to the virtual file. |
| 1198 | InputStream inputStream = descriptor.createInputStream(); |
| 1199 | } |
| 1200 | } |
| 1201 | } catch (Exception ex) { |
| 1202 | Log.e("EXCEPTION", "ERROR: ", ex); |
| 1203 | } |
| 1204 | } |
| 1205 | </pre> |
| 1206 | |
| 1207 | <p> |
| 1208 | For more information about accessing user files, see the |
| 1209 | <a href="{@docRoot}guide/topics/providers/document-provider.html">Storage |
| 1210 | Access Frameworks guide</a>. |
Eric Schmidt | 1231768 | 2016-05-10 08:40:53 -0700 | [diff] [blame] | 1211 | </p> |