blob: c7ffb7a06b76092a78dcdc2ed299d4df7a827b5c [file] [log] [blame]
Dirk Doughertycf65e4842016-03-07 22:31:57 -08001page.title=Android N for Developers
Dirk Dougherty43eb9512016-03-03 14:53:16 -08002meta.tags="preview", "androidn"
3page.tags="preview", "developer preview"
Dirk Doughertya6495a922016-03-04 15:21:59 -08004page.image=images/cards/card-n-apis_2x.png
Dirk Dougherty5748bc42016-02-06 18:24:32 -08005@jd:body
6
Dirk Doughertycf65e4842016-03-07 22:31:57 -08007
8
9
10<div id="qv-wrapper">
11<div id="qv">
David Friedman82c668f2016-05-17 23:53:21 -070012 <h2>Key Developer Features</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080013 <ol>
14 <ul style="list-style-type:none;">
David Friedman82c668f2016-05-17 23:53:21 -070015 <li><a href="#multi-window_support">Multi-window Support</a></li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080016 <li><a href="#notification_enhancements">Notifications</a></li>
David Friedman82c668f2016-05-17 23:53:21 -070017 <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 Friedman521da6a2016-06-14 15:37:16 -070021 <li><a href="#surfaceview">SurfaceView</a></li>
Dirk Dougherty59428922016-03-10 18:54:49 -080022 <li><a href="#data_saver">Data Saver</a></li>
Andrew Solovay097b1152016-04-06 17:33:00 -070023 <li><a href="#vulkan">Vulkan API</a></li>
Dirk Dougherty59428922016-03-10 18:54:49 -080024 <li><a href="#tile_api">Quick Settings Tile API</a></li>
David Friedman82c668f2016-05-17 23:53:21 -070025 <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 Schmidt700127a2016-05-12 16:29:18 -070028 <li><a href="#emoji">New Emojis</a></li>
Dirk Dougherty59428922016-03-10 18:54:49 -080029 <li><a href="#icu4">ICU4J APIs in Android</a></li>
Andrew Solovay1721c3e2016-07-15 13:04:04 -070030 <li><a href="#webview">WebView</a></li>
Dirk Dougherty59428922016-03-10 18:54:49 -080031 <li><a href="#gles_32">OpenGL ES 3.2 API</a></li>
David Friedman82c668f2016-05-17 23:53:21 -070032 <li><a href="#android_tv_recording">Android TV Recording</a></li>
Dirk Dougherty59428922016-03-10 18:54:49 -080033 <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 Friedman82c668f2016-05-17 23:53:21 -070039 <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 Friedman93970ba2016-05-13 01:23:13 -070041 <li><a href="#keyboard_shortcuts_helper">Keyboard Shortcuts Helper</a></li>
Hemal Patel37663db2016-06-13 14:37:36 -070042 <li><a href="#custom_pointer_api">Custom Pointer API</a></li>
David Friedman93970ba2016-05-13 01:23:13 -070043 <li><a href="#sustained_performance_api">Sustained Performance API</a></li>
David Friedman182e8b52016-05-13 10:03:52 -070044 <li><a href="#vr">VR Support</a></li>
David Friedman82c668f2016-05-17 23:53:21 -070045 <li><a href="#print_svc">Print Service Enhancements</a></li>
Eric Schmidt186fada2016-04-27 11:48:22 -070046 <li><a href="#virtual_files">Virtual Files</a></li>
David Friedman93970ba2016-05-13 01:23:13 -070047 <li><a href="#framemetrics_api">FrameMetricsListener API</a></li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080048 </ol>
49</div>
50</div>
51
52
53
54<p>Android N is still in active development, but you can try it
55now as part of the N Developer Preview. The sections below highlight some of
56the new features for developers. </p>
57
Andrew Solovay9b218572016-03-09 11:17:07 -080058<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 Doughertycf65e4842016-03-07 22:31:57 -080066
David Friedman82c668f2016-05-17 23:53:21 -070067<h2 id="multi-window_support">Multi-window Support</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080068
69
70<p>In Android N, we're introducing a new and much-requested multitasking feature
71into the platform &mdash; 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
76running Android N, users can run two apps side-by-side or
77one-above-the-other in splitscreen mode. Users can resize the apps by dragging
78the divider between them. </li>
79
Andrew Solovay9b218572016-03-09 11:17:07 -080080<li>On Android TV devices, apps can put themselves in <a
81href="{@docRoot}preview/features/picture-in-picture.html">picture-in-picture
82mode</a>, allowing them to continue showing content while the user browses or
Daniel Yu0ab19aa2016-03-14 15:35:38 -070083interacts with other apps.</li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080084 </ul>
85
Dirk Doughertycf65e4842016-03-07 22:31:57 -080086<div class="col-4of10">
Dirk Dougherty59428922016-03-10 18:54:49 -080087<img src="{@docRoot}preview/images/mw-portrait.png" alt="" style="height:460px;padding-left:1em;"
Dirk Doughertycf65e4842016-03-07 22:31:57 -080088 id="img-split-screen" />
89<p class="img-caption">
Dirk Dougherty59428922016-03-10 18:54:49 -080090 <strong>Figure 1.</strong> Apps running in split-screen mode.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080091</p>
David Friedman182e8b52016-05-13 10:03:52 -070092
Dirk Doughertycf65e4842016-03-07 22:31:57 -080093 </div>
94
Dirk Doughertycf65e4842016-03-07 22:31:57 -080095<p>Especially on tablets and other larger-screen devices, multi-window support
96gives you new ways to engage users. You can even enable drag-and-drop in
97your app to let users conveniently drag content to or from your app &mdash; a great
98way to enhance your user experience. </p>
99
100<p>It's straightforward to add multi-window support to your app and configure how it
101handles multi-window display. For example, you can specify your activity's
102minimum allowable dimensions, preventing users from resizing the activity below
103that 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 Solovay9b218572016-03-09 11:17:07 -0800106<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 Doughertycf65e4842016-03-07 22:31:57 -0800111
David Friedman82c668f2016-05-17 23:53:21 -0700112<h2 id="notification_enhancements">Notification Enhancements</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800113
114<p>In Android N we've redesigned notifications to make them easier and faster to
115use. Some of the changes include:</p>
116
117<ul>
Andrew Solovay9b218572016-03-09 11:17:07 -0800118 <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 Schmidt80448222016-05-31 11:56:03 -0700125 <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 Schmidt57a83b52016-05-10 12:37:38 -0700129 </li>
130
131 <li>
Andrew Solovay9b218572016-03-09 11:17:07 -0800132 <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 Solovay069ac632016-03-11 11:23:27 -0800136 this model.
Andrew Solovay9b218572016-03-09 11:17:07 -0800137 </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 Doughertycf65e4842016-03-07 22:31:57 -0800150</ul>
151
152<div class="col-4of12">
Andrew Solovay9b218572016-03-09 11:17:07 -0800153 <img src="{@docRoot}preview/images/notifications-1.png" alt=""
154 style="padding:.5em;max-width:226px">
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800155</div>
Andrew Solovay9b218572016-03-09 11:17:07 -0800156
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800157<div class="col-4of12">
Andrew Solovay9b218572016-03-09 11:17:07 -0800158 <img src="{@docRoot}preview/images/notifications-3.png" alt=""
159 style="padding:.5em;max-width:226px">
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800160</div>
Andrew Solovay9b218572016-03-09 11:17:07 -0800161
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800162<div class="col-4of12">
Andrew Solovay9b218572016-03-09 11:17:07 -0800163 <img src="{@docRoot}preview/images/notifications-2.png" alt=""
164 style="padding:.5em;max-width:226px">
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800165</div>
166
167
168<p class="img-caption">
Adarsh Fernando37601562016-03-09 09:53:57 -0800169 <strong>Figure 2.</strong> Bundled notifications and direct reply.
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800170</p>
171
Andrew Solovay9b218572016-03-09 11:17:07 -0800172<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 Doughertycf65e4842016-03-07 22:31:57 -0800175
176
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800177
David Friedman82c668f2016-05-17 23:53:21 -0700178<h2 id="jit_aot">Profile-guided JIT/AOT Compilation</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800179
180<p>In Android N, we've added a Just in Time (JIT) compiler with code profiling to
181ART, which lets it constantly improve the performance of Android apps as they
182run. The JIT compiler complements ART's current Ahead of Time (AOT) compiler
183and helps improve runtime performance, save storage space, and speed up app
184updates and system updates.</p>
185
186<p>Profile-guided compilation lets ART manage the AOT/JIT compilation for each app
187according to its actual usage, as well as conditions on the device. For
188example, ART maintains a profile of each app's hot methods and can precompile
189and cache those methods for best performance. It leaves other parts of the app
190uncompiled until they are actually used.</p>
191
192<p>Besides improving performance for key parts of the app, profile-guided
193compilation helps reduce an app's overall RAM footprint, including associated
194binaries. 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
197device battery. It does precompilation only when then the device is idle and
198charging, saving time and battery by doing that work in advance.</p>
199
David Friedman82c668f2016-05-17 23:53:21 -0700200<h2 id="quick_path_to_app_install">Quick Path to App Install</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800201
202<p>One of the most tangible benefits of ART's JIT compiler is the speed of app
203installs and system updates. Even large apps that required several minutes to
204optimize and install in Android 6.0 can now install in just a matter of
205seconds. System updates are also faster, since there's no more optimizing step. </p>
206
David Friedman82c668f2016-05-17 23:53:21 -0700207<h2 id="doze_on_the_go">Doze on the Go...</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800208
209<p>Android 6.0 introduced Doze, a system mode that saves battery by deferring
210apps' CPU and network activities when the device is idle, such as when it's
211sitting 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.
214Any time the screen is off for a period of time and the device is unplugged,
215Doze applies a subset of the familiar CPU and network restrictions to apps.
216This means users can save battery even when carrying their devices in their
217pockets.</p>
218
219
Dirk Dougherty59428922016-03-10 18:54:49 -0800220<img src="/preview/images/doze-diagram-1.png"
221 alt="" id="figure1" />
222<p class="img-caption">
Andrew Solovay069ac632016-03-11 11:23:27 -0800223 <strong>Figure 3.</strong> Doze now applies
Dirk Dougherty59428922016-03-10 18:54:49 -0800224 restrictions to improve battery life even when the device is not stationary.
225</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800226
227
228<p>A short time after the screen turns off while the device is on battery, Doze
229restricts network access and defers jobs and syncs. During brief maintenance
230windows, applications are allowed network access and any of their deferred
231jobs/syncs are executed. Turning the screen on or plugging in the device brings
232the device out of Doze.</p>
233
234<p>When the device is stationary again, with screen off and on battery for a
235period of time, Doze applies the full CPU and network restrictions on {@link
236android.os.PowerManager.WakeLock}, {@link android.app.AlarmManager} alarms, and
237GPS/Wi-Fi scans.</p>
238
239<p>The best practices for adapting your app to Doze are the same whether the
240device is moving or not, so if you already updated your app to gracefully
241handle Doze, you're all set. If not, start <a
Andrew Solovay9b218572016-03-09 11:17:07 -0800242href="{@docRoot}training/monitoring-device-state/doze-standby.html#assessing_your_app">adapting
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800243your app to Doze</a> now.</p>
244
David Friedman82c668f2016-05-17 23:53:21 -0700245<h2 id="background_optimizations">Project Svelte: Background Optimizations</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800246
247<p>Project Svelte is an ongoing effort to minimize RAM use by system and apps
248across the range of Android devices in the ecosystem. In Android N, Project
249Svelte 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
252can make your user experience amazing &mdash; immediate, fast, and context-aware.
253When not handled right, background processing can needlessly consume RAM (and
254battery) and affect system performance for other apps. </p>
255
Andrew Solovayd6a6f962016-03-10 15:01:29 -0800256<p>Since Android 5.0, {@link android.app.job.JobScheduler} has been the
257preferred way of performing background work in a way that's good
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800258for users. Apps can schedule jobs while letting the system optimize based on
259memory, power, and connectivity conditions. JobScheduler offers control and
260simplicity, and we want all apps to use it. </p>
261
Andrew Solovay9b218572016-03-09 11:17:07 -0800262<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 Doughertycf65e4842016-03-07 22:31:57 -0800269
Andrew Solovayd6a6f962016-03-10 15:01:29 -0800270<p>We're continuing to extend <code>JobScheduler</code> and
271<code>GCMNetworkManager</code> to meet more of
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800272your use cases &mdash; for example, in Android N you can now schedule background
273work based on changes in Content Providers. At the same time we're starting to
274deprecate some of the older patterns that can reduce system performance,
275especially on low-memory devices.</p>
276
277<p>In Android N we're removing three commonly-used implicit broadcasts &mdash;
Adarsh Fernando37601562016-03-09 09:53:57 -0800278 {@link android.net.ConnectivityManager#CONNECTIVITY_ACTION}, {@link
279 android.hardware.Camera#ACTION_NEW_PICTURE}, and {@link
280 android.hardware.Camera#ACTION_NEW_VIDEO} &mdash; since those can wake the
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800281background processes of multiple apps at once and strain memory and battery. If
282your 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 Solovay9b218572016-03-09 11:17:07 -0800285<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 Doughertycf65e4842016-03-07 22:31:57 -0800290
David Friedman521da6a2016-06-14 15:37:16 -0700291<h2 id="surfaceview">SurfaceView</h2>
292<p>
293Android N brings synchronous movement to the {@link android.view.SurfaceView}
294class, which provides better battery performance
295than {@link android.view.TextureView} in certain cases: When rendering video or
2963D 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
300The {@link android.view.SurfaceView} class enables more battery-efficient compositing on
301screen, because it is composited in dedicated hardware, separately from app
302window content. As a result, it makes fewer intermediate
303copies than {@link android.view.TextureView}.
304</p>
305
306<p>
307A {@link android.view.SurfaceView} object's content position is now updated synchronously
308with the containing app content. One result of this change is that simple
309translations or scales of a video playing in a {@link android.view.SurfaceView}
310no longer produce black bars alongside the view as it moves.
311</p>
312
313<p>
314Starting 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 Dougherty59428922016-03-10 18:54:49 -0800317
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
329exceeds the cost of the device itself. For many users, cellular data is an
330expensive resource that they want to conserve. </p>
331
332<p>Android N introduces Data Saver mode, a new system service that helps reduce
333cellular data use by apps, whether roaming, near the end of the billing cycle,
334or on a small prepaid data pack. Data Saver gives users control over how apps
335use cellular data and lets developers provide more efficient service when Data
336Saver is on. </p>
337
338<p>When a user enables Data Saver in <strong>Settings</strong> and the device is
339on a metered network, the system blocks background data usage and signals apps
340to use less data in the foreground wherever possible &mdash; such as by limiting
341bit rate for streaming, reducing image quality, deferring optimistic precaching,
342and so on. Users can whitelist specific apps to allow background metered data
343usage even when Data Saver is turned on.</p>
344
345<p>Android N extends the {@link android.net.ConnectivityManager} to provide apps a
346way to <a href="{@docRoot}preview/features/data-saver.html#status">retrieve the
347user's Data Saver preferences</a> and <a
348href="{@docRoot}preview/features/data-saver.html#monitor-changes">monitor
349preference changes</a>. All apps should check whether the user has enabled Data
350Saver and make an effort to limit foreground and background data usage.</p>
351
352
Andrew Solovay097b1152016-04-06 17:33:00 -0700353<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 Friedman93970ba2016-05-13 01:23:13 -0700391 such as Nexus 5X, Nexus 6P, and Nexus Player. We're working closely with our
Andrew Solovay097b1152016-04-06 17:33:00 -0700392 partners to bring Vulkan to more devices as soon as possible.
393</p>
394
395<p>
Andrew Solovayf5266e52016-04-12 17:32:57 -0700396 For more information, see the the <a href=
397 "{@docRoot}ndk/guides/graphics/index.html">API documentation</a>.
Andrew Solovay097b1152016-04-06 17:33:00 -0700398</p>
399
Dirk Dougherty59428922016-03-10 18:54:49 -0800400<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,
412directly from the notification shade. In Android N, we've expanded the scope of
413Quick 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
416access across a paginated display area by swiping left or right. We've also
417given users control over what Quick Settings tiles appear and where they are
418displayed &mdash; 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 Friedman182e8b52016-05-13 10:03:52 -0700435 For information about creating an app tile, see the documentation for
Dirk Dougherty59428922016-03-10 18:54:49 -0800436 <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 Friedman82c668f2016-05-17 23:53:21 -0700442<h2 id="number-blocking">Number Blocking</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800443
David Friedman82c668f2016-05-17 23:53:21 -0700444<p>Android N now supports number blocking in the platform and provides a
Dirk Dougherty59428922016-03-10 18:54:49 -0800445framework API to let service providers maintain a blocked-number list. The
Andrew Solovayef935042016-03-14 14:25:36 -0700446default SMS app, the default phone app, and carrier apps can read from and
Dirk Dougherty59428922016-03-10 18:54:49 -0800447write to the blocked-number list. The list is not accessible to other apps.</p>
448
David Friedman82c668f2016-05-17 23:53:21 -0700449<p>By making number blocking a standard feature of the platform, Android provides
450a consistent way for apps to support number blocking across a wide range of
Dirk Dougherty59428922016-03-10 18:54:49 -0800451devices. 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 &amp;
456Restore 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
461read the blocked numbers list on the device and perform service-side blocking
462for the user in order to stop unwanted calls and texts from reaching the user
463through 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 Friedman82c668f2016-05-17 23:53:21 -0700471<h2 id="call_screening">Call Screening</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800472
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 Friedman82c668f2016-05-17 23:53:21 -0700493<h2 id="multi-locale_languages">Multi-locale Support, More Languages</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800494
495
496<p>Android N now lets users select <strong>multiple locales</strong> in Settings,
497to better support bilingual use-cases. Apps can use
498a new API to get the user's selected locales and then offer more sophisticated
499user experiences for multi-locale users &mdash; such as showing search results in
500multiple languages and not offering to translate webpages in a language the
501user already knows.</p>
502
503<p>Along with multi-locale support, Android N also expands the range of languages
504available to users. It offers more than 25 variants each for commonly used
505languages such as English, Spanish, French, and Arabic. It also adds partial
506support for more than 100 new languages.</p>
507
David Friedman182e8b52016-05-13 10:03:52 -0700508<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
510changing the way that it resolves resources. Make sure that you test and verify that your apps
Dirk Dougherty59428922016-03-10 18:54:49 -0800511working 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
514should follow, see <a href="{@docRoot}preview/features/multilingual-support.html"
515>Multilingual Support</a>.</p>
516
Eric Schmidt700127a2016-05-12 16:29:18 -0700517
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 Dougherty59428922016-03-10 18:54:49 -0800560<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 Solovay1721c3e2016-07-15 13:04:04 -0700577<h2 id="webview">WebView</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800578
Andrew Solovay1721c3e2016-07-15 13:04:04 -0700579<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 Dougherty59428922016-03-10 18:54:49 -0800656
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800657<h2 id="gles_32">OpenGL&trade; 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 Friedman182e8b52016-05-13 10:03:52 -0700663href="https://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
664Android Extension Pack</a></a> (AEP) except for <code>EXT_texture_sRGB_decode</code>.
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800665 <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 Solovay9b218572016-03-09 11:17:07 -0800672requirement in your manifest file, using the <code>&lt;uses-feature&gt;</code> tag and
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800673the <code>android:glEsVersion</code> attribute. </p>
674
675<p>For information about using OpenGL ES, including how to check a device's
676supported OpenGL ES version at runtime, see the <a
677href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL ES API guide</a>.</p>
678
679
David Friedman82c668f2016-05-17 23:53:21 -0700680<h2 id="android_tv_recording">Android TV Recording</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800681
682<p>Android N adds the ability to record and playback content from Android TV input
683services via new recording APIs. Building on top of existing time-shifting
684APIs, TV input services can control what channel data can be recorded, how
685recorded sessions are saved, and manage user interaction with recorded content. </p>
686
687<p>For more information, see <a
688href="{@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 Hufnagleb6d17232016-03-22 11:29:03 -0700694Some highlights are below &mdash; for a complete list of changes, see
695<a href="{@docRoot}preview/features/afw.html">Android for Work Updates</a>.</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800696
697<h3 id="work_profile_security_challenge">Work profile security challenge </h3>
698
699<p>
Andrew Solovay097b1152016-04-06 17:33:00 -0700700 Profile owners targeting the N SDK
701 can specify a separate security challenge for apps running in
Dirk Dougherty59428922016-03-10 18:54:49 -0800702 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 Solovay097b1152016-04-06 17:33:00 -0700711 Profile owners can set distinct passcode policies for the work challenge
Dirk Dougherty59428922016-03-10 18:54:49 -0800712 (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
724off the managed user is temporarily shut down, which disables work profile
725apps, background sync, and notifications. This includes the profile owner
726application. When work mode is off, the system displays a persistent status
727icon to remind the user that they can't launch work apps. The launcher
728indicates 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
733through a specified VPN. The system automatically starts that VPN after the
734device 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
743interaction, VPN clients need to handle new entry points for Always on VPN. As
744before, services are indicated to the system by an intent filter matching
745action <code>android.net.VpnService</code>. </p>
746
747<p>
748 Users can also manually set Always on VPN clients that implement
Andrew Solovay1721c3e2016-07-15 13:04:04 -0700749 <code>VPNService</code> methods using
750 <strong>Settings&gt;More&gt;Vpn</strong>. The option to enable Always on VPN
751 from Settings is available only if VPN client targets API level 24.
Dirk Dougherty59428922016-03-10 18:54:49 -0800752</p>
753
Andrew Solovay097b1152016-04-06 17:33:00 -0700754<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 Friedman82c668f2016-05-17 23:53:21 -0700764<h2 id="accessibility_enhancements">Accessibility Enhancements</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800765
766<p>Android N now offers Vision Settings directly on the Welcome screen for new
767device setup. This makes it much easier for users to discover and configure
768accessibility features on their devices, including magnification gesture, font
769size, display size, and TalkBack. </p>
770
771<p>With these accessibility features getting more prominent placement, your users
772are more likely to try your app with them enabled. Make sure you test your apps
773early with these settings enabled. You can enable them from Settings >
774Accessibility.</p>
775
776<p>Also in Android N, accessibility services can now help users with motor
777impairments to touch the screen. The new API allows building services with
778features such as face-tracking, eye-tracking, point scanning, and so on, to
779meet the needs of those users.</p>
780
781<p>For more information, see <code>android.accessibilityservice.GestureDescription</code>
Eric Schmidt57a83b52016-05-10 12:37:38 -0700782 in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800783
784
David Friedman82c668f2016-05-17 23:53:21 -0700785<h2 id="direct_boot">Direct Boot</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800786
787<p>Direct boot improves device startup times and lets registered
788apps have limited functionality even after an unexpected reboot.
789For example, if an encrypted device reboots while the user is sleeping,
David Friedman93970ba2016-05-13 01:23:13 -0700790registered alarms, messages and incoming calls can now continue to notify
Dirk Dougherty59428922016-03-10 18:54:49 -0800791the 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
795to enable fine grained encryption policies for both system and app data.
796The system uses a device-encrypted store for select system data and explicitly
797registered 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
801device-encrypted data only, and without general access to apps or data.
802If you have components that you want to run in this mode, you can register
803them by setting a flag in the manifest. After restart, the system activates
804registered components by broadcasting the <code>LOCKED_BOOT_COMPLETED</code>
805intent. The system ensures registered device-encrypted app data is available
806before unlock. All other data is unavailable until the User confirms their lock
807 screen credentials to decrypt it. </p>
808
809For more information, see <a href="{@docRoot}preview/features/direct-boot.html">Direct Boot</a>.</p>
810</p>
811
Dirk Dougherty59428922016-03-10 18:54:49 -0800812<h2 id="key_attestation">Key Attestation</h2>
813
Kevin Hufnagle23239ca2016-06-09 16:02:31 -0700814<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 Dougherty59428922016-03-10 18:54:49 -0800826
Kevin Hufnagle23239ca2016-06-09 16:02:31 -0700827<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 Dougherty59428922016-03-10 18:54:49 -0800837
Kevin Hufnagle0da25a62016-07-14 12:32:52 -0700838<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 Hufnagle23239ca2016-06-09 16:02:31 -0700852<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 Dougherty59428922016-03-10 18:54:49 -0800857
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)
861connections safely, without any code modification, by using the declarative
862<em>Network Security Config</em> instead of using the conventional
863error-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
868Certificate Authorities (CA) are trusted for its secure connections. For
869example, 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
872secure connections of their application without added risk to the installed
873base.
874</li>
875<li><b>Cleartext traffic opt-out.</b> Lets an application protect itself from
876accidental 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
882href="{@docRoot}preview/features/security-config.html">Network Security
883Config</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
888and no longer trust user-added Certificate Authorities (CA). Apps targeting Android
889N that wish to trust user-added CAs should use the
890<a href="{@docRoot}preview/features/security-config.html">Network Security Config</a> to
891specify how user CAs should be trusted.</p>
892
David Friedman82c668f2016-05-17 23:53:21 -0700893<h2 id="apk_signature_v2">APK Signature Scheme v2</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800894
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700895<p>
896 Android N introduces APK Signature Scheme v2, a new app-signing scheme that
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700897 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 Hufnagle7cd4a102016-05-04 15:30:45 -0700901</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800902
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700903<p>
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700904 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 Hufnagle7cd4a102016-05-04 15:30:45 -0700912</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800913
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700914<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 Hufnagleaa1b7dd2016-05-11 17:38:45 -0700930<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 Hufnagle7cd4a102016-05-04 15:30:45 -0700936<p>
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700937 For more information, read the Android Studio documents that describe how to
smain@google.com73cf8222016-05-19 16:30:43 -0700938 <a href="{@docRoot}studio/publish/app-signing.html#release-mode">
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700939 sign an app</a> in Android Studio and how to <a href=
smain@google.com73cf8222016-05-19 16:30:43 -0700940 "{@docRoot}studio/build/build-variants.html#signing"> configure
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700941 the build file for signing apps</a> using the Android Plugin for Gradle.
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700942</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800943
David Friedman82c668f2016-05-17 23:53:21 -0700944<h2 id="scoped_directory_access">Scoped Directory Access</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800945
946<p>In Android N, apps can use new APIs to request access to specific <a
947href="{@docRoot}guide/topics/data/data-storage.html#filesExternal">external
948storage</a> directories, including directories on removable media such as SD
949cards. The new APIs greatly simplify how your application accesses standard
950external storage directories, such as the <code>Pictures</code> directory. Apps
951like photo apps can use these APIs instead of using
952<code>READ_EXTERNAL_STORAGE</code>, which grants access to all storage
953directories, or the Storage Access Framework, which makes the user navigate to
954the directory.</p>
955
956<p>Additionally, the new APIs simplify the steps a user takes to grant external
957storage access to your app. When you use the new APIs, the system uses a simple
958permissions UI that clearly details what directory the application is
959requesting access to.</p>
960
961<p>For more information, see the
962<a href="{@docRoot}preview/features/scoped-folder-access.html">Scoped
963Directory Access</a> developer documentation.</p>
964
David Friedman93970ba2016-05-13 01:23:13 -0700965<h2 id="keyboard_shortcuts_helper">Keyboard Shortcuts Helper</h2>
966
967<p>
Hemal Pateldd4a8e72016-06-07 18:22:21 -0700968 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 Friedman93970ba2016-05-13 01:23:13 -0700983</p>
984
David Friedman93970ba2016-05-13 01:23:13 -0700985<p>
Hemal Pateldd4a8e72016-06-07 18:22:21 -0700986 To trigger Keyboard Shortcuts Helper from anywhere in your app, call
987 {@code Activity.requestKeyboardShortcutsHelper()} for the relevant activity.
David Friedman93970ba2016-05-13 01:23:13 -0700988</p>
989
Hemal Patel37663db2016-06-13 14:37:36 -0700990<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 Friedman93970ba2016-05-13 01:23:13 -07001010<h2 id="sustained_performance_api">Sustained Performance API</h2>
1011
1012<p>
1013Performance can fluctuate dramatically for long-running apps, because the
1014system throttles system-on-chip engines as device components reach their
1015temperature limits. This fluctuation presents a moving target for app
1016developers creating high-performance, long-running apps.
1017</p>
1018
1019<p>
1020To address these limitations, Android N includes support for
David Friedman182e8b52016-05-13 10:03:52 -07001021<em>sustained performance mode</em>, enabling OEMs to provide hints about
1022device-performance capabilities for long-running apps. App developers
1023can use these hints to tune apps for a predictable,
David Friedman93970ba2016-05-13 01:23:13 -07001024consistent level of device performance over long periods of time.
1025</p>
1026
1027<p>
1028App developers can try out this new API in the N Developer Preview on
1029Nexus 6P devices only. To use this feature,
1030set the sustained performance window flag for the window
1031you want to run in sustained performance mode. Set this flag using the
David Friedman182e8b52016-05-13 10:03:52 -07001032{@code Window.setSustainedPerformanceMode()} method. The system automatically
David Friedman93970ba2016-05-13 01:23:13 -07001033disables this mode when the window is no longer in focus.
1034</p>
1035
David Friedman182e8b52016-05-13 10:03:52 -07001036<h2 id="vr">VR Support</h2>
1037
1038<p>
David Friedman20237392016-05-17 15:31:25 -07001039Android N adds platform support and optimizations for a new VR Mode to let developers
1040build high-quality mobile VR experiences for users. There are a number of performance
1041enhancements, including access to an exclusive CPU core for VR apps.
1042Within your apps, you can take advantage of intelligent head-tracking,
1043and stereo notifications that work for VR. Most importantly, Android N provides for
1044very low latency graphics. For complete information about building VR apps for Android N,
1045see the <a href="https://developers.google.com/vr/android/">Google VR SDK for Android</a>.
1046</p>
David Friedman182e8b52016-05-13 10:03:52 -07001047
1048
Andrew Solovay097b1152016-04-06 17:33:00 -07001049<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 Schmidt186fada2016-04-27 11:48:22 -07001089
David Friedman93970ba2016-05-13 01:23:13 -07001090<h2 id="framemetrics_api">FrameMetricsListener API</h2>
1091
1092<p>
1093The FrameMetricsListener API allows an app to monitor its UI rendering
David Friedman182e8b52016-05-13 10:03:52 -07001094performance. The API provides this capability by exposing a streaming Pub/Sub API to transfer frame
David Friedman93970ba2016-05-13 01:23:13 -07001095timing info for the app's current window. The data returned is
David Friedman20237392016-05-17 15:31:25 -07001096equivalent to that which <code><a href="{@docRoot}tools/help/shell.html#shellcommands">adb shell</a>
1097dumpsys gfxinfo framestats</code> displays, but is not limited to the past 120 frames.
David Friedman93970ba2016-05-13 01:23:13 -07001098</p>
1099
1100<p>
1101You can use FrameMetricsListener to measure interaction-level UI
1102performance in production, without a USB connection. This API
1103allows collection of data at a much higher granularity than does
1104{@code adb shell dumpsys gfxinfo}. This higher granularity is possible because
1105the system can collect data for particular interactions in the app; the system
1106need not capture a global summary of the entire app’s
1107performance, or clear any global state. You can use this
1108capability to gather performance data and catch regressions in UI performance
1109for real use cases within an app.
1110</p>
1111
1112<p>
David Friedman182e8b52016-05-13 10:03:52 -07001113To monitor a window, implement the <code>FrameMetricsListener.onMetricsAvailable()</code>
1114callback method and register it on that window. For more information, refer to
1115the {@code FrameMetricsListener} class documentation in
1116the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.
David Friedman93970ba2016-05-13 01:23:13 -07001117</p>
1118
David Friedman93970ba2016-05-13 01:23:13 -07001119<p>
David Friedman182e8b52016-05-13 10:03:52 -07001120The API provides a {@code FrameMetrics} object, which contains timing data that
David Friedman93970ba2016-05-13 01:23:13 -07001121the rendering subsystem reports for various milestones in a frame lifecycle.
1122The 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 Friedman182e8b52016-05-13 10:03:52 -07001126{@code TOTAL_DURATION}, and {@code FIRST_DRAW_FRAME}.
David Friedman93970ba2016-05-13 01:23:13 -07001127</p>
1128
1129
Eric Schmidt186fada2016-04-27 11:48:22 -07001130<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 &#64;Override
1172 public void onActivityResult(int requestCode, int resultCode,
1173 Intent resultData) {
1174 try {
1175 if (requestCode == REQUEST_CODE &amp;&amp;
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 Schmidt12317682016-05-10 08:40:53 -07001211</p>