blob: 606b38fdd691764d3dc0790ba242a4aa7c479cc2 [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>
Dirk Dougherty59428922016-03-10 18:54:49 -080021 <li><a href="#data_saver">Data Saver</a></li>
Andrew Solovay097b1152016-04-06 17:33:00 -070022 <li><a href="#vulkan">Vulkan API</a></li>
Dirk Dougherty59428922016-03-10 18:54:49 -080023 <li><a href="#tile_api">Quick Settings Tile API</a></li>
David Friedman82c668f2016-05-17 23:53:21 -070024 <li><a href="#number-blocking">Number Blocking</a></li>
25 <li><a href="#call_screening">Call Screening</a></li>
26 <li><a href="#multi-locale_languages">Locales and Languages</a></li>
Eric Schmidt700127a2016-05-12 16:29:18 -070027 <li><a href="#emoji">New Emojis</a></li>
Dirk Dougherty59428922016-03-10 18:54:49 -080028 <li><a href="#icu4">ICU4J APIs in Android</a></li>
29 <li><a href="#gles_32">OpenGL ES 3.2 API</a></li>
David Friedman82c668f2016-05-17 23:53:21 -070030 <li><a href="#android_tv_recording">Android TV Recording</a></li>
Dirk Dougherty59428922016-03-10 18:54:49 -080031 <li><a href="#android_for_work">Android for Work</a></li>
32 <li><a href="#accessibility_enhancements">Accessibility</a></li>
33 <li><a href="#direct_boot">Direct Boot</a></li>
34 <li><a href="#key_attestation">Key Attestation</a></li>
35 <li><a href="#network_security_config">Network Security Config</a></li>
36 <li><a href="#default_trusted_ca">Default Trusted CA</a></li>
David Friedman82c668f2016-05-17 23:53:21 -070037 <li><a href="#apk_signature_v2">APK Signature Scheme v2</a></li>
38 <li><a href="#scoped_directory_access">Scoped Directory Access</a></li>
David Friedman93970ba2016-05-13 01:23:13 -070039 <li><a href="#keyboard_shortcuts_helper">Keyboard Shortcuts Helper</a></li>
40 <li><a href="#sustained_performance_api">Sustained Performance API</a></li>
David Friedman182e8b52016-05-13 10:03:52 -070041 <li><a href="#vr">VR Support</a></li>
David Friedman82c668f2016-05-17 23:53:21 -070042 <li><a href="#print_svc">Print Service Enhancements</a></li>
Eric Schmidt186fada2016-04-27 11:48:22 -070043 <li><a href="#virtual_files">Virtual Files</a></li>
David Friedman93970ba2016-05-13 01:23:13 -070044 <li><a href="#framemetrics_api">FrameMetricsListener API</a></li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080045 </ol>
46</div>
47</div>
48
49
50
51<p>Android N is still in active development, but you can try it
52now as part of the N Developer Preview. The sections below highlight some of
53the new features for developers. </p>
54
Andrew Solovay9b218572016-03-09 11:17:07 -080055<p>
56 Make sure to check out the <a href=
57 "{@docRoot}preview/behavior-changes.html">Behavior Changes</a> to learn about
58 areas where platform changes may affect your apps, take a look at the
59 developer guides to learn more about key features, and download the <a href=
60 "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a> for details on
61 new APIs.
62</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080063
David Friedman82c668f2016-05-17 23:53:21 -070064<h2 id="multi-window_support">Multi-window Support</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080065
66
67<p>In Android N, we're introducing a new and much-requested multitasking feature
68into the platform &mdash; multi-window support. </p>
69
70 <p>Users can now pop open two apps on the screen at once. </p>
71 <ul>
72 <li>On phones and tablets
73running Android N, users can run two apps side-by-side or
74one-above-the-other in splitscreen mode. Users can resize the apps by dragging
75the divider between them. </li>
76
Andrew Solovay9b218572016-03-09 11:17:07 -080077<li>On Android TV devices, apps can put themselves in <a
78href="{@docRoot}preview/features/picture-in-picture.html">picture-in-picture
79mode</a>, allowing them to continue showing content while the user browses or
Daniel Yu0ab19aa2016-03-14 15:35:38 -070080interacts with other apps.</li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080081 </ul>
82
Dirk Doughertycf65e4842016-03-07 22:31:57 -080083<div class="col-4of10">
Dirk Dougherty59428922016-03-10 18:54:49 -080084<img src="{@docRoot}preview/images/mw-portrait.png" alt="" style="height:460px;padding-left:1em;"
Dirk Doughertycf65e4842016-03-07 22:31:57 -080085 id="img-split-screen" />
86<p class="img-caption">
Dirk Dougherty59428922016-03-10 18:54:49 -080087 <strong>Figure 1.</strong> Apps running in split-screen mode.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080088</p>
David Friedman182e8b52016-05-13 10:03:52 -070089
Dirk Doughertycf65e4842016-03-07 22:31:57 -080090 </div>
91
Dirk Doughertycf65e4842016-03-07 22:31:57 -080092<p>Especially on tablets and other larger-screen devices, multi-window support
93gives you new ways to engage users. You can even enable drag-and-drop in
94your app to let users conveniently drag content to or from your app &mdash; a great
95way to enhance your user experience. </p>
96
97<p>It's straightforward to add multi-window support to your app and configure how it
98handles multi-window display. For example, you can specify your activity's
99minimum allowable dimensions, preventing users from resizing the activity below
100that size. You can also disable multi-window display for your app, which
101 ensures that the system will only show your app in full-screen mode.</p>
102
Andrew Solovay9b218572016-03-09 11:17:07 -0800103<p>
104 For more information, see the <a href=
105 "{@docRoot}preview/features/multi-window.html">Multi-Window Support</a>
106 developer documentation.
107</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800108
David Friedman82c668f2016-05-17 23:53:21 -0700109<h2 id="notification_enhancements">Notification Enhancements</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800110
111<p>In Android N we've redesigned notifications to make them easier and faster to
112use. Some of the changes include:</p>
113
114<ul>
Andrew Solovay9b218572016-03-09 11:17:07 -0800115 <li>
116 <strong>Template updates</strong>: We're updating notification templates to
117 put a new emphasis on hero image and avatar. Developers will be able to
118 take advantage of the new templates with minimal adjustments in their code.
119 </li>
120
121 <li>
Eric Schmidt80448222016-05-31 11:56:03 -0700122 <strong>Messaging style customization</strong>: You can customize more of
123 the user interface labels associated with your notifications using the
124 <code>MessagingStyle</code> class. You can configure the message,
125 conversation title, and content view.
Eric Schmidt57a83b52016-05-10 12:37:38 -0700126 </li>
127
128 <li>
Andrew Solovay9b218572016-03-09 11:17:07 -0800129 <strong>Bundled notifications</strong>: The system can group messages
130 together, for example by message topic, and display the group. A user can
131 take actions, such as Dismiss or Archive, on them in place. If you’ve
132 implemented notifications for Android Wear, you’ll already be familiar with
Andrew Solovay069ac632016-03-11 11:23:27 -0800133 this model.
Andrew Solovay9b218572016-03-09 11:17:07 -0800134 </li>
135
136 <li>
137 <strong>Direct reply</strong>: For real-time communication apps, the
138 Android system supports inline replies so that users can quickly respond to
139 an SMS or text message directly within the notification interface.
140 </li>
141
142 <li>
143 <strong>Custom views</strong>: Two new APIs enable you to leverage system
144 decorations, such as notification headers and actions, when using custom
145 views in notifications.
146 </li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800147</ul>
148
149<div class="col-4of12">
Andrew Solovay9b218572016-03-09 11:17:07 -0800150 <img src="{@docRoot}preview/images/notifications-1.png" alt=""
151 style="padding:.5em;max-width:226px">
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800152</div>
Andrew Solovay9b218572016-03-09 11:17:07 -0800153
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800154<div class="col-4of12">
Andrew Solovay9b218572016-03-09 11:17:07 -0800155 <img src="{@docRoot}preview/images/notifications-3.png" alt=""
156 style="padding:.5em;max-width:226px">
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800157</div>
Andrew Solovay9b218572016-03-09 11:17:07 -0800158
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800159<div class="col-4of12">
Andrew Solovay9b218572016-03-09 11:17:07 -0800160 <img src="{@docRoot}preview/images/notifications-2.png" alt=""
161 style="padding:.5em;max-width:226px">
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800162</div>
163
164
165<p class="img-caption">
Adarsh Fernando37601562016-03-09 09:53:57 -0800166 <strong>Figure 2.</strong> Bundled notifications and direct reply.
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800167</p>
168
Andrew Solovay9b218572016-03-09 11:17:07 -0800169<p>To learn how to implement the new features, see the
170 <a href="{@docRoot}preview/features/notification-updates.html">Notifications</a>
171 guide.</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800172
173
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800174
David Friedman82c668f2016-05-17 23:53:21 -0700175<h2 id="jit_aot">Profile-guided JIT/AOT Compilation</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800176
177<p>In Android N, we've added a Just in Time (JIT) compiler with code profiling to
178ART, which lets it constantly improve the performance of Android apps as they
179run. The JIT compiler complements ART's current Ahead of Time (AOT) compiler
180and helps improve runtime performance, save storage space, and speed up app
181updates and system updates.</p>
182
183<p>Profile-guided compilation lets ART manage the AOT/JIT compilation for each app
184according to its actual usage, as well as conditions on the device. For
185example, ART maintains a profile of each app's hot methods and can precompile
186and cache those methods for best performance. It leaves other parts of the app
187uncompiled until they are actually used.</p>
188
189<p>Besides improving performance for key parts of the app, profile-guided
190compilation helps reduce an app's overall RAM footprint, including associated
191binaries. This feature is especially important on low-memory devices.</p>
192
193<p>ART manages profile-guided compilation in a way that minimizes impact on the
194device battery. It does precompilation only when then the device is idle and
195charging, saving time and battery by doing that work in advance.</p>
196
David Friedman82c668f2016-05-17 23:53:21 -0700197<h2 id="quick_path_to_app_install">Quick Path to App Install</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800198
199<p>One of the most tangible benefits of ART's JIT compiler is the speed of app
200installs and system updates. Even large apps that required several minutes to
201optimize and install in Android 6.0 can now install in just a matter of
202seconds. System updates are also faster, since there's no more optimizing step. </p>
203
David Friedman82c668f2016-05-17 23:53:21 -0700204<h2 id="doze_on_the_go">Doze on the Go...</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800205
206<p>Android 6.0 introduced Doze, a system mode that saves battery by deferring
207apps' CPU and network activities when the device is idle, such as when it's
208sitting on a table or in a drawer. </p>
209
210<p>Now in Android N, Doze takes a step further and saves battery while on the go.
211Any time the screen is off for a period of time and the device is unplugged,
212Doze applies a subset of the familiar CPU and network restrictions to apps.
213This means users can save battery even when carrying their devices in their
214pockets.</p>
215
216
Dirk Dougherty59428922016-03-10 18:54:49 -0800217<img src="/preview/images/doze-diagram-1.png"
218 alt="" id="figure1" />
219<p class="img-caption">
Andrew Solovay069ac632016-03-11 11:23:27 -0800220 <strong>Figure 3.</strong> Doze now applies
Dirk Dougherty59428922016-03-10 18:54:49 -0800221 restrictions to improve battery life even when the device is not stationary.
222</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800223
224
225<p>A short time after the screen turns off while the device is on battery, Doze
226restricts network access and defers jobs and syncs. During brief maintenance
227windows, applications are allowed network access and any of their deferred
228jobs/syncs are executed. Turning the screen on or plugging in the device brings
229the device out of Doze.</p>
230
231<p>When the device is stationary again, with screen off and on battery for a
232period of time, Doze applies the full CPU and network restrictions on {@link
233android.os.PowerManager.WakeLock}, {@link android.app.AlarmManager} alarms, and
234GPS/Wi-Fi scans.</p>
235
236<p>The best practices for adapting your app to Doze are the same whether the
237device is moving or not, so if you already updated your app to gracefully
238handle Doze, you're all set. If not, start <a
Andrew Solovay9b218572016-03-09 11:17:07 -0800239href="{@docRoot}training/monitoring-device-state/doze-standby.html#assessing_your_app">adapting
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800240your app to Doze</a> now.</p>
241
David Friedman82c668f2016-05-17 23:53:21 -0700242<h2 id="background_optimizations">Project Svelte: Background Optimizations</h2>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800243
244<p>Project Svelte is an ongoing effort to minimize RAM use by system and apps
245across the range of Android devices in the ecosystem. In Android N, Project
246Svelte is focused on optimizing the way apps run in the background. </p>
247
248<p>Background processing is an essential part of most apps. When handled right, it
249can make your user experience amazing &mdash; immediate, fast, and context-aware.
250When not handled right, background processing can needlessly consume RAM (and
251battery) and affect system performance for other apps. </p>
252
Andrew Solovayd6a6f962016-03-10 15:01:29 -0800253<p>Since Android 5.0, {@link android.app.job.JobScheduler} has been the
254preferred way of performing background work in a way that's good
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800255for users. Apps can schedule jobs while letting the system optimize based on
256memory, power, and connectivity conditions. JobScheduler offers control and
257simplicity, and we want all apps to use it. </p>
258
Andrew Solovay9b218572016-03-09 11:17:07 -0800259<p>
260 Another good option is <a href=
261 "https://developers.google.com/android/reference/com/google/android/gms/gcm/GcmNetworkManager">
262 <code>GCMNetworkManager</code></a>, part of Google Play Services, which
263 offers similar job scheduling with compatibility across legacy versions of
264 Android.
265</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800266
Andrew Solovayd6a6f962016-03-10 15:01:29 -0800267<p>We're continuing to extend <code>JobScheduler</code> and
268<code>GCMNetworkManager</code> to meet more of
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800269your use cases &mdash; for example, in Android N you can now schedule background
270work based on changes in Content Providers. At the same time we're starting to
271deprecate some of the older patterns that can reduce system performance,
272especially on low-memory devices.</p>
273
274<p>In Android N we're removing three commonly-used implicit broadcasts &mdash;
Adarsh Fernando37601562016-03-09 09:53:57 -0800275 {@link android.net.ConnectivityManager#CONNECTIVITY_ACTION}, {@link
276 android.hardware.Camera#ACTION_NEW_PICTURE}, and {@link
277 android.hardware.Camera#ACTION_NEW_VIDEO} &mdash; since those can wake the
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800278background processes of multiple apps at once and strain memory and battery. If
279your app is receiving these, take advantage of the N Developer Preview to
280 migrate to <code>JobScheduler</code> and related APIs instead. </p>
281
Andrew Solovay9b218572016-03-09 11:17:07 -0800282<p>
283 Take a look at the <a href=
284 "{@docRoot}preview/features/background-optimization.html">Background
285 Optimizations</a> documentation for details.
286</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800287
Dirk Dougherty59428922016-03-10 18:54:49 -0800288
289<h2 id="data_saver">Data Saver</h2>
290
291<div class="col-5of12" style="margin-right:1.5em;">
292<img src="{@docRoot}preview/images/datasaver.png" style="border:2px solid #ddd">
293
294<p class="img-caption" style="padding-right:2em;">
295 <strong>Figure 4.</strong> Data Saver in Settings.
296</p>
297 </div>
298
299<p>Over the life of a mobile device, the cost of a cellular data plan typically
300exceeds the cost of the device itself. For many users, cellular data is an
301expensive resource that they want to conserve. </p>
302
303<p>Android N introduces Data Saver mode, a new system service that helps reduce
304cellular data use by apps, whether roaming, near the end of the billing cycle,
305or on a small prepaid data pack. Data Saver gives users control over how apps
306use cellular data and lets developers provide more efficient service when Data
307Saver is on. </p>
308
309<p>When a user enables Data Saver in <strong>Settings</strong> and the device is
310on a metered network, the system blocks background data usage and signals apps
311to use less data in the foreground wherever possible &mdash; such as by limiting
312bit rate for streaming, reducing image quality, deferring optimistic precaching,
313and so on. Users can whitelist specific apps to allow background metered data
314usage even when Data Saver is turned on.</p>
315
316<p>Android N extends the {@link android.net.ConnectivityManager} to provide apps a
317way to <a href="{@docRoot}preview/features/data-saver.html#status">retrieve the
318user's Data Saver preferences</a> and <a
319href="{@docRoot}preview/features/data-saver.html#monitor-changes">monitor
320preference changes</a>. All apps should check whether the user has enabled Data
321Saver and make an effort to limit foreground and background data usage.</p>
322
323
Andrew Solovay097b1152016-04-06 17:33:00 -0700324<h2 id="vulkan">Vulkan API</h2>
325
326<p>
327 Android N integrates <a href="http://www.khronos.org/vulkan" class=
328 "external-link">Vulkan™</a>, a new 3D rendering API, into the platform. Like
329 <a href="https://www.khronos.org/opengles/" class="external-link">OpenGL™
330 ES</a>, Vulkan is an open standard for 3D graphics and rendering maintained
331 by the Khronos Group.
332</p>
333
334<p>
335 Vulkan is designed from the ground up to minimize CPU overhead in the driver,
336 and allow your application to control GPU operation more directly. Vulkan
337 also enables better parallelization by allowing multiple threads to perform
338 work such as command buffer construction at once.
339</p>
340
341<p>
342 Vulkan development tools and libraries are rolled into the Android NDK. They
343 include:
344</p>
345
346<ul>
347 <li>Headers
348 </li>
349
350 <li>Validation layers (debug libraries)
351 </li>
352
353 <li>SPIR-V shader compiler
354 </li>
355
356 <li>SPIR-V runtime shader compilation library
357 </li>
358</ul>
359
360<p>
361 Vulkan is only available to apps on devices with Vulkan-capable hardware,
David Friedman93970ba2016-05-13 01:23:13 -0700362 such as Nexus 5X, Nexus 6P, and Nexus Player. We're working closely with our
Andrew Solovay097b1152016-04-06 17:33:00 -0700363 partners to bring Vulkan to more devices as soon as possible.
364</p>
365
366<p>
Andrew Solovayf5266e52016-04-12 17:32:57 -0700367 For more information, see the the <a href=
368 "{@docRoot}ndk/guides/graphics/index.html">API documentation</a>.
Andrew Solovay097b1152016-04-06 17:33:00 -0700369</p>
370
Dirk Dougherty59428922016-03-10 18:54:49 -0800371<h2 id="tile_api">Quick Settings Tile API</h2>
372
373
374<div style="float:right;max-width:320px">
375<img src="{@docRoot}preview/images/quicksettings.png" style="padding-left:1.5em;">
376
377<p class="img-caption" style="padding-left:2em;">
378 <strong>Figure 5.</strong> Quick Settings tiles in the notification shade.
379</p>
380
381
382 </div><p>Quick Settings is a popular and simple way to expose key settings and actions,
383directly from the notification shade. In Android N, we've expanded the scope of
384Quick Settings to make it even more useful and convenient. </p>
385
386<p>We've added more room for additional Quick Settings tiles, which users can
387access across a paginated display area by swiping left or right. We've also
388given users control over what Quick Settings tiles appear and where they are
389displayed &mdash; users can add or move tiles just by dragging and dropping them. </p>
390
391<p>For developers, Android N also adds a new API that lets you define your own
392 Quick Settings tiles to give users easy access to key controls and actions in your app.</p>
393
394<p>
395 Quick Settings tiles are reserved for controls or actions that are either
396 urgently required or frequently used, and should not be used as shortcuts to
397 launching an app.
398</p>
399
400<p>
401 Once you’ve defined your tiles, you can surface them to users, who can add
402 them to Quick Settings just by drag and drop.
403</p>
404
405<p>
David Friedman182e8b52016-05-13 10:03:52 -0700406 For information about creating an app tile, see the documentation for
Dirk Dougherty59428922016-03-10 18:54:49 -0800407 <code>android.service.quicksettings.Tile</code> in the downloadable <a href=
408 "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.
409</p>
410
411
412
David Friedman82c668f2016-05-17 23:53:21 -0700413<h2 id="number-blocking">Number Blocking</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800414
David Friedman82c668f2016-05-17 23:53:21 -0700415<p>Android N now supports number blocking in the platform and provides a
Dirk Dougherty59428922016-03-10 18:54:49 -0800416framework API to let service providers maintain a blocked-number list. The
Andrew Solovayef935042016-03-14 14:25:36 -0700417default SMS app, the default phone app, and carrier apps can read from and
Dirk Dougherty59428922016-03-10 18:54:49 -0800418write to the blocked-number list. The list is not accessible to other apps.</p>
419
David Friedman82c668f2016-05-17 23:53:21 -0700420<p>By making number blocking a standard feature of the platform, Android provides
421a consistent way for apps to support number blocking across a wide range of
Dirk Dougherty59428922016-03-10 18:54:49 -0800422devices. Among the other benefits that apps can take advantage of are:</p>
423
424<ul>
425 <li> Numbers blocked on calls are also blocked on texts
426 <li> Blocked numbers can persist across resets and devices through the Backup &amp;
427Restore feature
428 <li> Multiple apps can use the same blocked numbers list
429</ul>
430
431<p>Additionally, carrier app integration through Android means that carriers can
432read the blocked numbers list on the device and perform service-side blocking
433for the user in order to stop unwanted calls and texts from reaching the user
434through any medium, such as a VOIP endpoint or forwarding phones.</p>
435
436<p>
437 For more information, see <code>android.provider.BlockedNumberContract</code>
438 in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API
439 Reference</a>.
440</p>
441
David Friedman82c668f2016-05-17 23:53:21 -0700442<h2 id="call_screening">Call Screening</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800443
444<p>
445 Android N allows the default phone app to screen incoming calls. The phone
446 app does this by implementing the new <code>CallScreeningService</code>,
447 which allows the phone app to perform a number of actions based on an
448 incoming call's {@link android.telecom.Call.Details Call.Details}, such as:
449</p>
450
451<ul>
452 <li> Reject the incoming call
453 <li> Do not allow the call to the call log
454 <li> Do not show the user a notification for the call
455</ul>
456
457<p>
458 For more information, see <code>android.telecom.CallScreeningService</code>
459 in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API
460 Reference</a>.
461</p>
462
463
David Friedman82c668f2016-05-17 23:53:21 -0700464<h2 id="multi-locale_languages">Multi-locale Support, More Languages</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800465
466
467<p>Android N now lets users select <strong>multiple locales</strong> in Settings,
468to better support bilingual use-cases. Apps can use
469a new API to get the user's selected locales and then offer more sophisticated
470user experiences for multi-locale users &mdash; such as showing search results in
471multiple languages and not offering to translate webpages in a language the
472user already knows.</p>
473
474<p>Along with multi-locale support, Android N also expands the range of languages
475available to users. It offers more than 25 variants each for commonly used
476languages such as English, Spanish, French, and Arabic. It also adds partial
477support for more than 100 new languages.</p>
478
David Friedman182e8b52016-05-13 10:03:52 -0700479<p>Apps can get the list of locales set by the user by calling
480<code>LocaleList.GetDefault()</code>. To support the expanded number of locales, Android N is
481changing the way that it resolves resources. Make sure that you test and verify that your apps
Dirk Dougherty59428922016-03-10 18:54:49 -0800482working as expected with the new resource resolution logic.</p>
483
484<p>To learn about the new resource-resolution behavior and the best practices you
485should follow, see <a href="{@docRoot}preview/features/multilingual-support.html"
486>Multilingual Support</a>.</p>
487
Eric Schmidt700127a2016-05-12 16:29:18 -0700488
489<h2 id="emoji">New Emojis</h2>
490
491<p>
492 Android N introduces additional emojis and emoji-related features including
493 skin tone emojis and support for variation
494 selectors. If your app supports emojis,
495 follow the guidelines below to take advantage of these emoji-related features.
496</p>
497
498<ul>
499 <li>
500 <strong>Check that a device contains an emoji before inserting it.</strong>
501 To check which emojis are present in the
502 system font, use the {@link android.graphics.Paint#hasGlyph(String)} method.
503 </li>
504 <li>
505 <strong>Check that an emoji supports variation selectors.</strong>
506 Variation selectors allow you to
507 present certain emojis in color or in black-and-white.
508 On mobile devices, apps should represent emojis in color rather than black-and-white. However,
509 if your app displays emojis inline with text, then it should use the black-and-white variation.
510 To determine whether an emoji has a variation, use the variation selector.
511 For a complete list of characters with variations, review the
512 <em>emoji variation sequences</em> section of the
513 <a class="external-link"
514 href="http://www.unicode.org/Public/9.0.0/ucd/StandardizedVariants-9.0.0d1.txt">
515 Unicode documentation on variations</a>.
516 </li>
517 <li>
518 <strong>Check that an emoji supports skin tone.</strong> Android N allows users to modify the
519 rendered skin tone of emojis to their preference. Keyboard apps should provide visual
520 indications for emojis that have multiple skin tones and should allow users to
521 select the skin tone that they prefer. To determine which system emojis have
522 skin tone modifiers, use the {@link android.graphics.Paint#hasGlyph(String)}
523 method. You can determine which emojis use skin tones by reading the
524 <a class="external-link"
525 href="http://unicode.org/emoji/charts/full-emoji-list.html">
526 Unicode documentation</a>.
527 </li>
528</ul>
529
530
Dirk Dougherty59428922016-03-10 18:54:49 -0800531<h2 id="icu4">ICU4J APIs in Android</h2>
532
533<p>
534 Android N now offers a subset of <a href=
535 "http://site.icu-project.org/">ICU4J</a> APIs in the Android framework under
536 the <code>android.icu</code> package. Migration is easy, and mostly entails
537 simply changing from the <code>com.java.icu</code> namespace to
538 <code>android.icu</code>. If you are already using an ICU4J bundle in your
539 apps, switching to the <code>android.icu</code> APIs provided in the Android
540 framework can produce substantial savings in APK size.
541</p>
542
543<p>
544 To learn more about the Android ICU4J APIs, see <a href=
545 "{@docRoot}preview/features/icu4j-framework.html">ICU4J Support</a>.
546</p>
547
548
549
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800550<h2 id="gles_32">OpenGL&trade; ES 3.2 API</h2>
551
552<p>Android N adds framework interfaces and platform support for OpenGL ES 3.2, including:</p>
553
554<ul>
555 <li> All extensions from the <a class="external-link"
David Friedman182e8b52016-05-13 10:03:52 -0700556href="https://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
557Android Extension Pack</a></a> (AEP) except for <code>EXT_texture_sRGB_decode</code>.
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800558 <li> Floating-point framebuffers for HDR and deferred shading.
559 <li> BaseVertex draw calls to enable better batching and streaming.
560 <li> Robust buffer access control to reduce WebGL overhead.
561</ul>
562
563<p>The framework API for OpenGL ES 3.2 on Android N is provided with the
564<code>GLES32</code> class. When using OpenGL ES 3.2, be sure to declare the
Andrew Solovay9b218572016-03-09 11:17:07 -0800565requirement in your manifest file, using the <code>&lt;uses-feature&gt;</code> tag and
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800566the <code>android:glEsVersion</code> attribute. </p>
567
568<p>For information about using OpenGL ES, including how to check a device's
569supported OpenGL ES version at runtime, see the <a
570href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL ES API guide</a>.</p>
571
572
David Friedman82c668f2016-05-17 23:53:21 -0700573<h2 id="android_tv_recording">Android TV Recording</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800574
575<p>Android N adds the ability to record and playback content from Android TV input
576services via new recording APIs. Building on top of existing time-shifting
577APIs, TV input services can control what channel data can be recorded, how
578recorded sessions are saved, and manage user interaction with recorded content. </p>
579
580<p>For more information, see <a
581href="{@docRoot}preview/features/tv-recording-api.html">Android TV Recording APIs</a>.</p>
582
583
584<h2 id="android_for_work">Android for Work</h2>
585
586<p>Android for Work adds many new features and APIs for devices running Android N.
Kevin Hufnagleb6d17232016-03-22 11:29:03 -0700587Some highlights are below &mdash; for a complete list of changes, see
588<a href="{@docRoot}preview/features/afw.html">Android for Work Updates</a>.</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800589
590<h3 id="work_profile_security_challenge">Work profile security challenge </h3>
591
592<p>
Andrew Solovay097b1152016-04-06 17:33:00 -0700593 Profile owners targeting the N SDK
594 can specify a separate security challenge for apps running in
Dirk Dougherty59428922016-03-10 18:54:49 -0800595 the work profile. The work challenge is shown when a user attempts to open
596 any work apps. Successful completion of the security challenge unlocks the
597 work profile and decrypts it if necessary. For profile owners,
598 <code>ACTION_SET_NEW_PASSWORD</code> prompts the user to set a work
599 challenge, and <code>ACTION_SET_NEW_PARENT_PROFILE_PASSWORD</code> prompts
600 the user to set a device lock.
601</p>
602
603<p>
Andrew Solovay097b1152016-04-06 17:33:00 -0700604 Profile owners can set distinct passcode policies for the work challenge
Dirk Dougherty59428922016-03-10 18:54:49 -0800605 (such as how long the PIN needs to be, or whether a fingerprint can be used
606 to unlock the profile) using the <code>setPasswordQuality()</code>,
607 <code>setPasswordMinimumLength()</code> and related methods. The profile
608 owner can also set the device lock using the <code>DevicePolicyManager</code>
609 instance returned by the new <code>getParentProfileInstance()</code> method.
610 Additionally, profile owners can customize the credentials screen for the
611 work challenge using the new <code>setOrganizationColor()</code> and
612 <code>setOrganizationName()</code> methods.
613</p>
614<h3 id="turn_off_work">Turn off work </h3>
615
616<p>On a device with a work profile, users can toggle work mode. When work mode is
617off the managed user is temporarily shut down, which disables work profile
618apps, background sync, and notifications. This includes the profile owner
619application. When work mode is off, the system displays a persistent status
620icon to remind the user that they can't launch work apps. The launcher
621indicates that work apps and widgets are not accessible. </p>
622
623<h3 id="always_on_vpn">Always on VPN </h3>
624
625<p>Device owners and profile owners can ensure that work apps always connect
626through a specified VPN. The system automatically starts that VPN after the
627device boots.</p>
628
629<p>
630 New <code>DevicePolicyManager</code> methods are
631 <code>setAlwaysOnVpnPackage()</code> and
632 <code>getAlwaysOnVpnPackage()</code>.
633</p>
634
635<p>Because VPN services can be bound directly by the system without app
636interaction, VPN clients need to handle new entry points for Always on VPN. As
637before, services are indicated to the system by an intent filter matching
638action <code>android.net.VpnService</code>. </p>
639
640<p>
641 Users can also manually set Always on VPN clients that implement
642 <code>VPNService</code> methods in the primary user using
643 <strong>Settings&gt;More&gt;Vpn</strong>.
644</p>
645
Andrew Solovay097b1152016-04-06 17:33:00 -0700646<h3 id="custom_provisioning">Customized provisioning</h3>
647
648<p>
649 An application can customize the profile owner and device owner provisioning
650 flows with corporate colors and logos.
651 <code>DevicePolicyManager.EXTRA_PROVISIONING_MAIN_COLOR</code> customizes
652 flow color. <code>DevicePolicyManager.EXTRA_PROVISIONING_LOGO_URI</code>
653 customizes the flow with a corporate logo.
654</p>
655
David Friedman82c668f2016-05-17 23:53:21 -0700656<h2 id="accessibility_enhancements">Accessibility Enhancements</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800657
658<p>Android N now offers Vision Settings directly on the Welcome screen for new
659device setup. This makes it much easier for users to discover and configure
660accessibility features on their devices, including magnification gesture, font
661size, display size, and TalkBack. </p>
662
663<p>With these accessibility features getting more prominent placement, your users
664are more likely to try your app with them enabled. Make sure you test your apps
665early with these settings enabled. You can enable them from Settings >
666Accessibility.</p>
667
668<p>Also in Android N, accessibility services can now help users with motor
669impairments to touch the screen. The new API allows building services with
670features such as face-tracking, eye-tracking, point scanning, and so on, to
671meet the needs of those users.</p>
672
673<p>For more information, see <code>android.accessibilityservice.GestureDescription</code>
Eric Schmidt57a83b52016-05-10 12:37:38 -0700674 in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800675
676
David Friedman82c668f2016-05-17 23:53:21 -0700677<h2 id="direct_boot">Direct Boot</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800678
679<p>Direct boot improves device startup times and lets registered
680apps have limited functionality even after an unexpected reboot.
681For example, if an encrypted device reboots while the user is sleeping,
David Friedman93970ba2016-05-13 01:23:13 -0700682registered alarms, messages and incoming calls can now continue to notify
Dirk Dougherty59428922016-03-10 18:54:49 -0800683the user as normal. This also means accessibility services can also be
684 available immediately after a restart.</p>
685
686<p>Direct boot takes advantage of file based encryption in Android N
687to enable fine grained encryption policies for both system and app data.
688The system uses a device-encrypted store for select system data and explicitly
689registered app data. By default a credential-encrypted store is used for all
690 other system data, user data, apps, and app data. </p>
691
692<p>At boot, the system starts in a restricted mode with access to
693device-encrypted data only, and without general access to apps or data.
694If you have components that you want to run in this mode, you can register
695them by setting a flag in the manifest. After restart, the system activates
696registered components by broadcasting the <code>LOCKED_BOOT_COMPLETED</code>
697intent. The system ensures registered device-encrypted app data is available
698before unlock. All other data is unavailable until the User confirms their lock
699 screen credentials to decrypt it. </p>
700
701For more information, see <a href="{@docRoot}preview/features/direct-boot.html">Direct Boot</a>.</p>
702</p>
703
Dirk Dougherty59428922016-03-10 18:54:49 -0800704<h2 id="key_attestation">Key Attestation</h2>
705
Kevin Hufnagle23239ca2016-06-09 16:02:31 -0700706<p>
707 Android N introduces <em>key attestation</em>, a new security tool that helps
708 you make sure that the key pairs stored within a device's <a class=
709 "external-link" href=
710 "https://source.android.com/security/keystore/"><em>hardware-backed
711 keystore</em></a> properly protect the sensitive information that your app
712 uses. By using this tool, you gain additional confidence that your app
713 interacts with keys that reside in secure hardware, even if the device
714 running your app is rooted. If you use keys from the hardware-backed keystore
715 in your apps, you should use this tool, particularly if you use the keys to
716 verify sensitive information within your app.
717</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800718
Kevin Hufnagle23239ca2016-06-09 16:02:31 -0700719<p>
720 Key attestation allows you to verify that an RSA or EC key pair has been
721 created and stored in a device’s hardware-backed keystore within the device’s
722 trusted execution environment (TEE). The tool also allows you to use an
723 off-device service, such as your app's back-end server, to determine and
724 strongly verify the uses and validity of the key pair. These features provide
725 an additional level of security that protects the key pair, even if someone
726 roots the device or compromises the security of the Android platform running
727 on the device.
728</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800729
Kevin Hufnagle23239ca2016-06-09 16:02:31 -0700730<p>
731 For more information, see the
732 <a href="{@docRoot}preview/features/key-attestation.html">Key Attestation</a>
733 developer documentation.
734</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800735
736<h2 id="network_security_config">Network Security Config</h2>
737
738<p>In Android N, apps can customize the behavior of their secure (HTTPS, TLS)
739connections safely, without any code modification, by using the declarative
740<em>Network Security Config</em> instead of using the conventional
741error-prone programmatic APIs (e.g. X509TrustManager).</p>
742
743 <p>Supported features:</p>
744<ul>
745<li><b>Custom trust anchors.</b> Lets an application customize which
746Certificate Authorities (CA) are trusted for its secure connections. For
747example, trusting particular self-signed certificates or a restricted set of public CAs.
748</li>
749<li><b>Debug-only overrides.</b> Lets an application developer safely debug
750secure connections of their application without added risk to the installed
751base.
752</li>
753<li><b>Cleartext traffic opt-out.</b> Lets an application protect itself from
754accidental usage of cleartext traffic.</li>
755<li><b>Certificate pinning.</b> An advanced feature that lets an application
756 limit which server keys are trusted for secure connections.</li>
757</ul>
758
759<p>For more information, see <a
760href="{@docRoot}preview/features/security-config.html">Network Security
761Config</a>.</p>
762
763<h2 id="default_trusted_ca">Default Trusted Certificate Authority</h2>
764
765<p>By default, apps that target Android N only trust system-provided certificates
766and no longer trust user-added Certificate Authorities (CA). Apps targeting Android
767N that wish to trust user-added CAs should use the
768<a href="{@docRoot}preview/features/security-config.html">Network Security Config</a> to
769specify how user CAs should be trusted.</p>
770
David Friedman82c668f2016-05-17 23:53:21 -0700771<h2 id="apk_signature_v2">APK Signature Scheme v2</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800772
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700773<p>
774 Android N introduces APK Signature Scheme v2, a new app-signing scheme that
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700775 offers faster app install times and more protection against unauthorized
776 alterations to APK files. By default, Android Studio 2.2 and the Android
777 Plugin for Gradle 2.2 sign your app using both APK Signature Scheme v2 and
778 the traditional signing scheme, which uses JAR signing.
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700779</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800780
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700781<p>
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700782 Although we recommend applying APK Signature Scheme v2 to your app, this new
783 scheme is not mandatory. If your app doesn't build properly when using APK
784 Signature Scheme v2, you can disable the new scheme. The disabling process
785 causes Android Studio 2.2 and the Android Plugin for Gradle 2.2 to sign your
786 app using only the traditional signing scheme. To sign with only the
787 traditional scheme, open the module-level <code>build.gradle</code> file, then
788 add the line <code>v2SigningEnabled false</code> to your release signing
789 configuration:
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700790</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800791
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700792<pre>
793 android {
794 ...
795 defaultConfig { ... }
796 signingConfigs {
797 release {
798 storeFile file("myreleasekey.keystore")
799 storePassword "password"
800 keyAlias "MyReleaseKey"
801 keyPassword "password"
802 <strong>v2SigningEnabled false</strong>
803 }
804 }
805 }
806</pre>
807
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700808<p class="caution"><strong>Caution: </strong> If you sign your app using APK
809 Signature Scheme v2 and make further changes to the app, the app's signature
810 is invalidated. For this reason, use tools such as <code>zipalign</code>
811 before signing your app using APK Signature Scheme v2, not after.
812</p>
813
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700814<p>
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700815 For more information, read the Android Studio documents that describe how to
smain@google.com73cf8222016-05-19 16:30:43 -0700816 <a href="{@docRoot}studio/publish/app-signing.html#release-mode">
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700817 sign an app</a> in Android Studio and how to <a href=
smain@google.com73cf8222016-05-19 16:30:43 -0700818 "{@docRoot}studio/build/build-variants.html#signing"> configure
Kevin Hufnagleaa1b7dd2016-05-11 17:38:45 -0700819 the build file for signing apps</a> using the Android Plugin for Gradle.
Kevin Hufnagle7cd4a102016-05-04 15:30:45 -0700820</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800821
David Friedman82c668f2016-05-17 23:53:21 -0700822<h2 id="scoped_directory_access">Scoped Directory Access</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800823
824<p>In Android N, apps can use new APIs to request access to specific <a
825href="{@docRoot}guide/topics/data/data-storage.html#filesExternal">external
826storage</a> directories, including directories on removable media such as SD
827cards. The new APIs greatly simplify how your application accesses standard
828external storage directories, such as the <code>Pictures</code> directory. Apps
829like photo apps can use these APIs instead of using
830<code>READ_EXTERNAL_STORAGE</code>, which grants access to all storage
831directories, or the Storage Access Framework, which makes the user navigate to
832the directory.</p>
833
834<p>Additionally, the new APIs simplify the steps a user takes to grant external
835storage access to your app. When you use the new APIs, the system uses a simple
836permissions UI that clearly details what directory the application is
837requesting access to.</p>
838
839<p>For more information, see the
840<a href="{@docRoot}preview/features/scoped-folder-access.html">Scoped
841Directory Access</a> developer documentation.</p>
842
David Friedman93970ba2016-05-13 01:23:13 -0700843<h2 id="keyboard_shortcuts_helper">Keyboard Shortcuts Helper</h2>
844
845<p>
David Friedman182e8b52016-05-13 10:03:52 -0700846In Android N, the user can press "Alt + /" to trigger a <em>Keyboard Shortcuts</em>
David Friedman93970ba2016-05-13 01:23:13 -0700847screen that displays all shortcuts available both from the system and from
848the app in focus. These are retrieved automatically from the app’s menu if
849available, but developers can provide their own fine-tuned shortcuts lists
David Friedman182e8b52016-05-13 10:03:52 -0700850for the screen. You can do this by overriding the new
851<code>Activity.onProvideKeyboardShortcuts()</code> method, described in the downloadable
852<a href="{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.
David Friedman93970ba2016-05-13 01:23:13 -0700853</p>
854
David Friedman93970ba2016-05-13 01:23:13 -0700855<p>
856To trigger the Keyboard Shortcuts Helper from anywhere in your app,
David Friedman182e8b52016-05-13 10:03:52 -0700857call {@code Activity.requestKeyboardShortcutsHelper()} for the relevant activity.
David Friedman93970ba2016-05-13 01:23:13 -0700858</p>
859
860<h2 id="sustained_performance_api">Sustained Performance API</h2>
861
862<p>
863Performance can fluctuate dramatically for long-running apps, because the
864system throttles system-on-chip engines as device components reach their
865temperature limits. This fluctuation presents a moving target for app
866developers creating high-performance, long-running apps.
867</p>
868
869<p>
870To address these limitations, Android N includes support for
David Friedman182e8b52016-05-13 10:03:52 -0700871<em>sustained performance mode</em>, enabling OEMs to provide hints about
872device-performance capabilities for long-running apps. App developers
873can use these hints to tune apps for a predictable,
David Friedman93970ba2016-05-13 01:23:13 -0700874consistent level of device performance over long periods of time.
875</p>
876
877<p>
878App developers can try out this new API in the N Developer Preview on
879Nexus 6P devices only. To use this feature,
880set the sustained performance window flag for the window
881you want to run in sustained performance mode. Set this flag using the
David Friedman182e8b52016-05-13 10:03:52 -0700882{@code Window.setSustainedPerformanceMode()} method. The system automatically
David Friedman93970ba2016-05-13 01:23:13 -0700883disables this mode when the window is no longer in focus.
884</p>
885
David Friedman182e8b52016-05-13 10:03:52 -0700886<h2 id="vr">VR Support</h2>
887
888<p>
David Friedman20237392016-05-17 15:31:25 -0700889Android N adds platform support and optimizations for a new VR Mode to let developers
890build high-quality mobile VR experiences for users. There are a number of performance
891enhancements, including access to an exclusive CPU core for VR apps.
892Within your apps, you can take advantage of intelligent head-tracking,
893and stereo notifications that work for VR. Most importantly, Android N provides for
894very low latency graphics. For complete information about building VR apps for Android N,
895see the <a href="https://developers.google.com/vr/android/">Google VR SDK for Android</a>.
896</p>
David Friedman182e8b52016-05-13 10:03:52 -0700897
898
Andrew Solovay097b1152016-04-06 17:33:00 -0700899<h2 id="print_svc">Print Service Enhancements</h2>
900
901<p>
902 In Android N, print service developers can now surface additional information
903 about individual printers and print jobs.
904</p>
905
906<p>
907 When listing individual printers, a print service can now set per-printer
908 icons in two ways:
909</p>
910
911<ul>
912 <li>You can set an icon from a resource ID by calling
913 <code>PrinterInfo.Builder.setResourceIconId()</code>
914 </li>
915
916 <li>You can show an icon from the network by calling
917 <code>PrinterInfo.Builder.setHasCustomPrinterIcon()</code>, and setting a
918 callback for when the icon is requested using
919 <code>android.printservice.PrinterDiscoverySession.onRequestCustomPrinterIcon()</code>
920 </li>
921</ul>
922
923<p>
924 In addition, you can provide a per-printer activity to display additional
925 information by calling <code>PrinterInfo.Builder.setInfoIntent()</code>.
926</p>
927
928<p>
929 You can indicate the progress and status of print jobs in the print job
930 notification by calling
931 <code>android.printservice.PrintJob.setProgress()</code> and
932 <code>android.printservice.PrintJob.setStatus()</code>, respectively.
933</p>
934
935<p>
936 For more information about these methods, see the downloadable <a href=
937 "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.
938</p>
Eric Schmidt186fada2016-04-27 11:48:22 -0700939
David Friedman93970ba2016-05-13 01:23:13 -0700940<h2 id="framemetrics_api">FrameMetricsListener API</h2>
941
942<p>
943The FrameMetricsListener API allows an app to monitor its UI rendering
David Friedman182e8b52016-05-13 10:03:52 -0700944performance. The API provides this capability by exposing a streaming Pub/Sub API to transfer frame
David Friedman93970ba2016-05-13 01:23:13 -0700945timing info for the app's current window. The data returned is
David Friedman20237392016-05-17 15:31:25 -0700946equivalent to that which <code><a href="{@docRoot}tools/help/shell.html#shellcommands">adb shell</a>
947dumpsys gfxinfo framestats</code> displays, but is not limited to the past 120 frames.
David Friedman93970ba2016-05-13 01:23:13 -0700948</p>
949
950<p>
951You can use FrameMetricsListener to measure interaction-level UI
952performance in production, without a USB connection. This API
953allows collection of data at a much higher granularity than does
954{@code adb shell dumpsys gfxinfo}. This higher granularity is possible because
955the system can collect data for particular interactions in the app; the system
956need not capture a global summary of the entire app’s
957performance, or clear any global state. You can use this
958capability to gather performance data and catch regressions in UI performance
959for real use cases within an app.
960</p>
961
962<p>
David Friedman182e8b52016-05-13 10:03:52 -0700963To monitor a window, implement the <code>FrameMetricsListener.onMetricsAvailable()</code>
964callback method and register it on that window. For more information, refer to
965the {@code FrameMetricsListener} class documentation in
966the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.
David Friedman93970ba2016-05-13 01:23:13 -0700967</p>
968
David Friedman93970ba2016-05-13 01:23:13 -0700969<p>
David Friedman182e8b52016-05-13 10:03:52 -0700970The API provides a {@code FrameMetrics} object, which contains timing data that
David Friedman93970ba2016-05-13 01:23:13 -0700971the rendering subsystem reports for various milestones in a frame lifecycle.
972The supported metrics are: {@code UNKNOWN_DELAY_DURATION},
973{@code INPUT_HANDLING_DURATION}, {@code ANIMATION_DURATION},
974{@code LAYOUT_MEASURE_DURATION}, {@code DRAW_DURATION}, {@code SYNC_DURATION},
975{@code COMMAND_ISSUE_DURATION}, {@code SWAP_BUFFERS_DURATION},
David Friedman182e8b52016-05-13 10:03:52 -0700976{@code TOTAL_DURATION}, and {@code FIRST_DRAW_FRAME}.
David Friedman93970ba2016-05-13 01:23:13 -0700977</p>
978
979
Eric Schmidt186fada2016-04-27 11:48:22 -0700980<h2 id="virtual_files">Virtual Files</h2>
981
982<p>
983 In previous versions of Android, your app could use the Storage Access
984 Framework to allow users to select files from their cloud storage accounts,
985 such as Google Drive. However, there was no way to represent files that did
986 not have a direct bytecode representation; every file was required to provide
987 an input stream.
988</p>
989
990<p>
991 Android N adds the concept of <em>virtual files</em> to the Storage Access
992 Framework. The virtual files feature allows your
993 {@link android.provider.DocumentsProvider} to return document URIs that can be
994 used with an {@link android.content.Intent#ACTION_VIEW} intent even if they
995 don't have a direct bytecode representation. Android N also allows you to
996 provide alternate formats for user files, virtual or otherwise.
997</p>
998
999<p>
1000 To get a URI for a virtual document in your app, first you create an
1001 {@link android.content.Intent} to open the file picker UI. Since an app
1002 cannot directly open a virtual file by using the
1003 {@link android.content.ContentResolver#openInputStream(Uri) openInputStream()}
1004 method, your app does not receive any virtual files if you include the
1005 {@link android.content.Intent#CATEGORY_OPENABLE} category.
1006</p>
1007
1008<p>
1009 After the user has made a selection, the system calls the
1010 {@link android.app.Activity#onActivityResult onActivityResult()} method.
1011 Your app can retrieve the URI of the virtual file and get an input stream, as
1012 demonstrated in the code snippet below.
1013</p>
1014
1015<pre>
1016 // Other Activity code ...
1017
1018 final static private int REQUEST_CODE = 64;
1019
1020 // We listen to the OnActivityResult event to respond to the user's selection.
1021 &#64;Override
1022 public void onActivityResult(int requestCode, int resultCode,
1023 Intent resultData) {
1024 try {
1025 if (requestCode == REQUEST_CODE &amp;&amp;
1026 resultCode == Activity.RESULT_OK) {
1027
1028 Uri uri = null;
1029
1030 if (resultData != null) {
1031 uri = resultData.getData();
1032
1033 ContentResolver resolver = getContentResolver();
1034
1035 // Before attempting to coerce a file into a MIME type,
1036 // check to see what alternative MIME types are available to
1037 // coerce this file into.
1038 String[] streamTypes =
1039 resolver.getStreamTypes(uri, "*/*");
1040
1041 AssetFileDescriptor descriptor =
1042 resolver.openTypedAssetFileDescriptor(
1043 uri,
1044 streamTypes[0],
1045 null);
1046
1047 // Retrieve a stream to the virtual file.
1048 InputStream inputStream = descriptor.createInputStream();
1049 }
1050 }
1051 } catch (Exception ex) {
1052 Log.e("EXCEPTION", "ERROR: ", ex);
1053 }
1054 }
1055</pre>
1056
1057<p>
1058 For more information about accessing user files, see the
1059 <a href="{@docRoot}guide/topics/providers/document-provider.html">Storage
1060 Access Frameworks guide</a>.
Eric Schmidt12317682016-05-10 08:40:53 -07001061</p>