blob: 9590ff61e7dec3e8e0940c917569ea58f3530550 [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">
12 <h2>Key developer features</h2>
13 <ol>
14 <ul style="list-style-type:none;">
15 <li><a href="#multi-window_support">Multi-window support</a></li>
16 <li><a href="#notification_enhancements">Notifications</a></li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080017 <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>
24 <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>
27 <li><a href="#icu4">ICU4J APIs in Android</a></li>
28 <li><a href="#gles_32">OpenGL ES 3.2 API</a></li>
29 <li><a href="#android_tv_recording">Android TV recording</a></li>
30 <li><a href="#android_for_work">Android for Work</a></li>
31 <li><a href="#accessibility_enhancements">Accessibility</a></li>
32 <li><a href="#direct_boot">Direct Boot</a></li>
33 <li><a href="#key_attestation">Key Attestation</a></li>
34 <li><a href="#network_security_config">Network Security Config</a></li>
35 <li><a href="#default_trusted_ca">Default Trusted CA</a></li>
Kevin Hufnaglea6a568d2016-04-11 14:11:45 -070036 <li><a href="#apk_signature_v2">APK signature scheme v2</a></li>
Dirk Dougherty59428922016-03-10 18:54:49 -080037 <li><a href="#scoped_directory_access">Scoped directory access</a></li>
Kevin Hufnagle93862ec2016-04-05 15:36:37 -070038 <li><a href="#launcher_shortcuts">Launcher shortcuts</a></li>
Andrew Solovay097b1152016-04-06 17:33:00 -070039 <li><a href="#print_svc">Print service enhancements</a></li>
Eric Schmidt186fada2016-04-27 11:48:22 -070040 <li><a href="#virtual_files">Virtual Files</a></li>
Eric Schmidt12317682016-05-10 08:40:53 -070041 <li><a href="#emoji">New Emojis</a></li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080042 </ol>
43</div>
44</div>
45
46
47
48<p>Android N is still in active development, but you can try it
49now as part of the N Developer Preview. The sections below highlight some of
50the new features for developers. </p>
51
Andrew Solovay9b218572016-03-09 11:17:07 -080052<p>
53 Make sure to check out the <a href=
54 "{@docRoot}preview/behavior-changes.html">Behavior Changes</a> to learn about
55 areas where platform changes may affect your apps, take a look at the
56 developer guides to learn more about key features, and download the <a href=
57 "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a> for details on
58 new APIs.
59</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080060
61<h2 id="multi-window_support">Multi-window support</h2>
62
63
64<p>In Android N, we're introducing a new and much-requested multitasking feature
65into the platform &mdash; multi-window support. </p>
66
67 <p>Users can now pop open two apps on the screen at once. </p>
68 <ul>
69 <li>On phones and tablets
70running Android N, users can run two apps side-by-side or
71one-above-the-other in splitscreen mode. Users can resize the apps by dragging
72the divider between them. </li>
73
Andrew Solovay9b218572016-03-09 11:17:07 -080074<li>On Android TV devices, apps can put themselves in <a
75href="{@docRoot}preview/features/picture-in-picture.html">picture-in-picture
76mode</a>, allowing them to continue showing content while the user browses or
Daniel Yu0ab19aa2016-03-14 15:35:38 -070077interacts with other apps.</li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080078 </ul>
79
Dirk Doughertycf65e4842016-03-07 22:31:57 -080080<div class="col-4of10">
Dirk Dougherty59428922016-03-10 18:54:49 -080081<img src="{@docRoot}preview/images/mw-portrait.png" alt="" style="height:460px;padding-left:1em;"
Dirk Doughertycf65e4842016-03-07 22:31:57 -080082 id="img-split-screen" />
83<p class="img-caption">
Dirk Dougherty59428922016-03-10 18:54:49 -080084 <strong>Figure 1.</strong> Apps running in split-screen mode.
Dirk Dougherty5748bc42016-02-06 18:24:32 -080085</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -080086 </div>
87
Dirk Doughertycf65e4842016-03-07 22:31:57 -080088<p>Especially on tablets and other larger-screen devices, multi-window support
89gives you new ways to engage users. You can even enable drag-and-drop in
90your app to let users conveniently drag content to or from your app &mdash; a great
91way to enhance your user experience. </p>
92
93<p>It's straightforward to add multi-window support to your app and configure how it
94handles multi-window display. For example, you can specify your activity's
95minimum allowable dimensions, preventing users from resizing the activity below
96that size. You can also disable multi-window display for your app, which
97 ensures that the system will only show your app in full-screen mode.</p>
98
Andrew Solovay9b218572016-03-09 11:17:07 -080099<p>
100 For more information, see the <a href=
101 "{@docRoot}preview/features/multi-window.html">Multi-Window Support</a>
102 developer documentation.
103</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800104
105<h2 id="notification_enhancements">Notification enhancements</h2>
106
107<p>In Android N we've redesigned notifications to make them easier and faster to
108use. Some of the changes include:</p>
109
110<ul>
Andrew Solovay9b218572016-03-09 11:17:07 -0800111 <li>
112 <strong>Template updates</strong>: We're updating notification templates to
113 put a new emphasis on hero image and avatar. Developers will be able to
114 take advantage of the new templates with minimal adjustments in their code.
115 </li>
116
117 <li>
118 <strong>Bundled notifications</strong>: The system can group messages
119 together, for example by message topic, and display the group. A user can
120 take actions, such as Dismiss or Archive, on them in place. If you’ve
121 implemented notifications for Android Wear, you’ll already be familiar with
Andrew Solovay069ac632016-03-11 11:23:27 -0800122 this model.
Andrew Solovay9b218572016-03-09 11:17:07 -0800123 </li>
124
125 <li>
126 <strong>Direct reply</strong>: For real-time communication apps, the
127 Android system supports inline replies so that users can quickly respond to
128 an SMS or text message directly within the notification interface.
129 </li>
130
131 <li>
132 <strong>Custom views</strong>: Two new APIs enable you to leverage system
133 decorations, such as notification headers and actions, when using custom
134 views in notifications.
135 </li>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800136</ul>
137
138<div class="col-4of12">
Andrew Solovay9b218572016-03-09 11:17:07 -0800139 <img src="{@docRoot}preview/images/notifications-1.png" alt=""
140 style="padding:.5em;max-width:226px">
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800141</div>
Andrew Solovay9b218572016-03-09 11:17:07 -0800142
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800143<div class="col-4of12">
Andrew Solovay9b218572016-03-09 11:17:07 -0800144 <img src="{@docRoot}preview/images/notifications-3.png" alt=""
145 style="padding:.5em;max-width:226px">
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800146</div>
Andrew Solovay9b218572016-03-09 11:17:07 -0800147
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800148<div class="col-4of12">
Andrew Solovay9b218572016-03-09 11:17:07 -0800149 <img src="{@docRoot}preview/images/notifications-2.png" alt=""
150 style="padding:.5em;max-width:226px">
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800151</div>
152
153
154<p class="img-caption">
Adarsh Fernando37601562016-03-09 09:53:57 -0800155 <strong>Figure 2.</strong> Bundled notifications and direct reply.
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800156</p>
157
Andrew Solovay9b218572016-03-09 11:17:07 -0800158<p>To learn how to implement the new features, see the
159 <a href="{@docRoot}preview/features/notification-updates.html">Notifications</a>
160 guide.</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800161
162
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800163
164<h2 id="jit_aot">Profile-guided JIT/AOT compilation</h2>
165
166<p>In Android N, we've added a Just in Time (JIT) compiler with code profiling to
167ART, which lets it constantly improve the performance of Android apps as they
168run. The JIT compiler complements ART's current Ahead of Time (AOT) compiler
169and helps improve runtime performance, save storage space, and speed up app
170updates and system updates.</p>
171
172<p>Profile-guided compilation lets ART manage the AOT/JIT compilation for each app
173according to its actual usage, as well as conditions on the device. For
174example, ART maintains a profile of each app's hot methods and can precompile
175and cache those methods for best performance. It leaves other parts of the app
176uncompiled until they are actually used.</p>
177
178<p>Besides improving performance for key parts of the app, profile-guided
179compilation helps reduce an app's overall RAM footprint, including associated
180binaries. This feature is especially important on low-memory devices.</p>
181
182<p>ART manages profile-guided compilation in a way that minimizes impact on the
183device battery. It does precompilation only when then the device is idle and
184charging, saving time and battery by doing that work in advance.</p>
185
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800186<h2 id="quick_path_to_app_install">Quick path to app install</h2>
187
188<p>One of the most tangible benefits of ART's JIT compiler is the speed of app
189installs and system updates. Even large apps that required several minutes to
190optimize and install in Android 6.0 can now install in just a matter of
191seconds. System updates are also faster, since there's no more optimizing step. </p>
192
193<h2 id="doze_on_the_go">Doze on the go...</h2>
194
195<p>Android 6.0 introduced Doze, a system mode that saves battery by deferring
196apps' CPU and network activities when the device is idle, such as when it's
197sitting on a table or in a drawer. </p>
198
199<p>Now in Android N, Doze takes a step further and saves battery while on the go.
200Any time the screen is off for a period of time and the device is unplugged,
201Doze applies a subset of the familiar CPU and network restrictions to apps.
202This means users can save battery even when carrying their devices in their
203pockets.</p>
204
205
Dirk Dougherty59428922016-03-10 18:54:49 -0800206<img src="/preview/images/doze-diagram-1.png"
207 alt="" id="figure1" />
208<p class="img-caption">
Andrew Solovay069ac632016-03-11 11:23:27 -0800209 <strong>Figure 3.</strong> Doze now applies
Dirk Dougherty59428922016-03-10 18:54:49 -0800210 restrictions to improve battery life even when the device is not stationary.
211</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800212
213
214<p>A short time after the screen turns off while the device is on battery, Doze
215restricts network access and defers jobs and syncs. During brief maintenance
216windows, applications are allowed network access and any of their deferred
217jobs/syncs are executed. Turning the screen on or plugging in the device brings
218the device out of Doze.</p>
219
220<p>When the device is stationary again, with screen off and on battery for a
221period of time, Doze applies the full CPU and network restrictions on {@link
222android.os.PowerManager.WakeLock}, {@link android.app.AlarmManager} alarms, and
223GPS/Wi-Fi scans.</p>
224
225<p>The best practices for adapting your app to Doze are the same whether the
226device is moving or not, so if you already updated your app to gracefully
227handle Doze, you're all set. If not, start <a
Andrew Solovay9b218572016-03-09 11:17:07 -0800228href="{@docRoot}training/monitoring-device-state/doze-standby.html#assessing_your_app">adapting
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800229your app to Doze</a> now.</p>
230
231<h2 id="background_optimizations">Project Svelte: Background optimizations</h2>
232
233<p>Project Svelte is an ongoing effort to minimize RAM use by system and apps
234across the range of Android devices in the ecosystem. In Android N, Project
235Svelte is focused on optimizing the way apps run in the background. </p>
236
237<p>Background processing is an essential part of most apps. When handled right, it
238can make your user experience amazing &mdash; immediate, fast, and context-aware.
239When not handled right, background processing can needlessly consume RAM (and
240battery) and affect system performance for other apps. </p>
241
Andrew Solovayd6a6f962016-03-10 15:01:29 -0800242<p>Since Android 5.0, {@link android.app.job.JobScheduler} has been the
243preferred way of performing background work in a way that's good
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800244for users. Apps can schedule jobs while letting the system optimize based on
245memory, power, and connectivity conditions. JobScheduler offers control and
246simplicity, and we want all apps to use it. </p>
247
Andrew Solovay9b218572016-03-09 11:17:07 -0800248<p>
249 Another good option is <a href=
250 "https://developers.google.com/android/reference/com/google/android/gms/gcm/GcmNetworkManager">
251 <code>GCMNetworkManager</code></a>, part of Google Play Services, which
252 offers similar job scheduling with compatibility across legacy versions of
253 Android.
254</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800255
Andrew Solovayd6a6f962016-03-10 15:01:29 -0800256<p>We're continuing to extend <code>JobScheduler</code> and
257<code>GCMNetworkManager</code> to meet more of
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800258your use cases &mdash; for example, in Android N you can now schedule background
259work based on changes in Content Providers. At the same time we're starting to
260deprecate some of the older patterns that can reduce system performance,
261especially on low-memory devices.</p>
262
263<p>In Android N we're removing three commonly-used implicit broadcasts &mdash;
Adarsh Fernando37601562016-03-09 09:53:57 -0800264 {@link android.net.ConnectivityManager#CONNECTIVITY_ACTION}, {@link
265 android.hardware.Camera#ACTION_NEW_PICTURE}, and {@link
266 android.hardware.Camera#ACTION_NEW_VIDEO} &mdash; since those can wake the
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800267background processes of multiple apps at once and strain memory and battery. If
268your app is receiving these, take advantage of the N Developer Preview to
269 migrate to <code>JobScheduler</code> and related APIs instead. </p>
270
Andrew Solovay9b218572016-03-09 11:17:07 -0800271<p>
272 Take a look at the <a href=
273 "{@docRoot}preview/features/background-optimization.html">Background
274 Optimizations</a> documentation for details.
275</p>
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800276
Dirk Dougherty59428922016-03-10 18:54:49 -0800277
278<h2 id="data_saver">Data Saver</h2>
279
280<div class="col-5of12" style="margin-right:1.5em;">
281<img src="{@docRoot}preview/images/datasaver.png" style="border:2px solid #ddd">
282
283<p class="img-caption" style="padding-right:2em;">
284 <strong>Figure 4.</strong> Data Saver in Settings.
285</p>
286 </div>
287
288<p>Over the life of a mobile device, the cost of a cellular data plan typically
289exceeds the cost of the device itself. For many users, cellular data is an
290expensive resource that they want to conserve. </p>
291
292<p>Android N introduces Data Saver mode, a new system service that helps reduce
293cellular data use by apps, whether roaming, near the end of the billing cycle,
294or on a small prepaid data pack. Data Saver gives users control over how apps
295use cellular data and lets developers provide more efficient service when Data
296Saver is on. </p>
297
298<p>When a user enables Data Saver in <strong>Settings</strong> and the device is
299on a metered network, the system blocks background data usage and signals apps
300to use less data in the foreground wherever possible &mdash; such as by limiting
301bit rate for streaming, reducing image quality, deferring optimistic precaching,
302and so on. Users can whitelist specific apps to allow background metered data
303usage even when Data Saver is turned on.</p>
304
305<p>Android N extends the {@link android.net.ConnectivityManager} to provide apps a
306way to <a href="{@docRoot}preview/features/data-saver.html#status">retrieve the
307user's Data Saver preferences</a> and <a
308href="{@docRoot}preview/features/data-saver.html#monitor-changes">monitor
309preference changes</a>. All apps should check whether the user has enabled Data
310Saver and make an effort to limit foreground and background data usage.</p>
311
312
Andrew Solovay097b1152016-04-06 17:33:00 -0700313<h2 id="vulkan">Vulkan API</h2>
314
315<p>
316 Android N integrates <a href="http://www.khronos.org/vulkan" class=
317 "external-link">Vulkan™</a>, a new 3D rendering API, into the platform. Like
318 <a href="https://www.khronos.org/opengles/" class="external-link">OpenGL™
319 ES</a>, Vulkan is an open standard for 3D graphics and rendering maintained
320 by the Khronos Group.
321</p>
322
323<p>
324 Vulkan is designed from the ground up to minimize CPU overhead in the driver,
325 and allow your application to control GPU operation more directly. Vulkan
326 also enables better parallelization by allowing multiple threads to perform
327 work such as command buffer construction at once.
328</p>
329
330<p>
331 Vulkan development tools and libraries are rolled into the Android NDK. They
332 include:
333</p>
334
335<ul>
336 <li>Headers
337 </li>
338
339 <li>Validation layers (debug libraries)
340 </li>
341
342 <li>SPIR-V shader compiler
343 </li>
344
345 <li>SPIR-V runtime shader compilation library
346 </li>
347</ul>
348
349<p>
350 Vulkan is only available to apps on devices with Vulkan-capable hardware,
Andrew Solovayf5266e52016-04-12 17:32:57 -0700351 such as Nexus 5X and Nexus 6P. We're working closely with our
Andrew Solovay097b1152016-04-06 17:33:00 -0700352 partners to bring Vulkan to more devices as soon as possible.
353</p>
354
355<p>
Andrew Solovayf5266e52016-04-12 17:32:57 -0700356 For more information, see the the <a href=
357 "{@docRoot}ndk/guides/graphics/index.html">API documentation</a>.
Andrew Solovay097b1152016-04-06 17:33:00 -0700358</p>
359
Dirk Dougherty59428922016-03-10 18:54:49 -0800360<h2 id="tile_api">Quick Settings Tile API</h2>
361
362
363<div style="float:right;max-width:320px">
364<img src="{@docRoot}preview/images/quicksettings.png" style="padding-left:1.5em;">
365
366<p class="img-caption" style="padding-left:2em;">
367 <strong>Figure 5.</strong> Quick Settings tiles in the notification shade.
368</p>
369
370
371 </div><p>Quick Settings is a popular and simple way to expose key settings and actions,
372directly from the notification shade. In Android N, we've expanded the scope of
373Quick Settings to make it even more useful and convenient. </p>
374
375<p>We've added more room for additional Quick Settings tiles, which users can
376access across a paginated display area by swiping left or right. We've also
377given users control over what Quick Settings tiles appear and where they are
378displayed &mdash; users can add or move tiles just by dragging and dropping them. </p>
379
380<p>For developers, Android N also adds a new API that lets you define your own
381 Quick Settings tiles to give users easy access to key controls and actions in your app.</p>
382
383<p>
384 Quick Settings tiles are reserved for controls or actions that are either
385 urgently required or frequently used, and should not be used as shortcuts to
386 launching an app.
387</p>
388
389<p>
390 Once you’ve defined your tiles, you can surface them to users, who can add
391 them to Quick Settings just by drag and drop.
392</p>
393
394<p>
395 For information about creating an app tile, see the
396 <code>android.service.quicksettings.Tile</code> in the downloadable <a href=
397 "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.
398</p>
399
400
401
402<h2 id="number-blocking">Number-blocking</h2>
403
404<p>Android N now supports number-blocking in the platform and provides a
405framework API to let service providers maintain a blocked-number list. The
Andrew Solovayef935042016-03-14 14:25:36 -0700406default SMS app, the default phone app, and carrier apps can read from and
Dirk Dougherty59428922016-03-10 18:54:49 -0800407write to the blocked-number list. The list is not accessible to other apps.</p>
408
409<p>By making number-blocking a standard feature of the platform, Android provides
410a consistent way for apps to support number-blocking across a wide range of
411devices. Among the other benefits that apps can take advantage of are:</p>
412
413<ul>
414 <li> Numbers blocked on calls are also blocked on texts
415 <li> Blocked numbers can persist across resets and devices through the Backup &amp;
416Restore feature
417 <li> Multiple apps can use the same blocked numbers list
418</ul>
419
420<p>Additionally, carrier app integration through Android means that carriers can
421read the blocked numbers list on the device and perform service-side blocking
422for the user in order to stop unwanted calls and texts from reaching the user
423through any medium, such as a VOIP endpoint or forwarding phones.</p>
424
425<p>
426 For more information, see <code>android.provider.BlockedNumberContract</code>
427 in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API
428 Reference</a>.
429</p>
430
431<h2 id="call_screening">Call screening</h2>
432
433<p>
434 Android N allows the default phone app to screen incoming calls. The phone
435 app does this by implementing the new <code>CallScreeningService</code>,
436 which allows the phone app to perform a number of actions based on an
437 incoming call's {@link android.telecom.Call.Details Call.Details}, such as:
438</p>
439
440<ul>
441 <li> Reject the incoming call
442 <li> Do not allow the call to the call log
443 <li> Do not show the user a notification for the call
444</ul>
445
446<p>
447 For more information, see <code>android.telecom.CallScreeningService</code>
448 in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API
449 Reference</a>.
450</p>
451
452
453<h2 id="multi-locale_languages">Multi-locale support, more languages</h2>
454
455
456<p>Android N now lets users select <strong>multiple locales</strong> in Settings,
457to better support bilingual use-cases. Apps can use
458a new API to get the user's selected locales and then offer more sophisticated
459user experiences for multi-locale users &mdash; such as showing search results in
460multiple languages and not offering to translate webpages in a language the
461user already knows.</p>
462
463<p>Along with multi-locale support, Android N also expands the range of languages
464available to users. It offers more than 25 variants each for commonly used
465languages such as English, Spanish, French, and Arabic. It also adds partial
466support for more than 100 new languages.</p>
467
468<p>Apps can get the list of locales set by the user by calling <code>LocaleList.GetDefault()</code>. To support the expanded number of locales, Android N is changing the way
469that it resolves resources. Make sure that you test and verify that your apps
470working as expected with the new resource resolution logic.</p>
471
472<p>To learn about the new resource-resolution behavior and the best practices you
473should follow, see <a href="{@docRoot}preview/features/multilingual-support.html"
474>Multilingual Support</a>.</p>
475
476<h2 id="icu4">ICU4J APIs in Android</h2>
477
478<p>
479 Android N now offers a subset of <a href=
480 "http://site.icu-project.org/">ICU4J</a> APIs in the Android framework under
481 the <code>android.icu</code> package. Migration is easy, and mostly entails
482 simply changing from the <code>com.java.icu</code> namespace to
483 <code>android.icu</code>. If you are already using an ICU4J bundle in your
484 apps, switching to the <code>android.icu</code> APIs provided in the Android
485 framework can produce substantial savings in APK size.
486</p>
487
488<p>
489 To learn more about the Android ICU4J APIs, see <a href=
490 "{@docRoot}preview/features/icu4j-framework.html">ICU4J Support</a>.
491</p>
492
493
494
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800495<h2 id="gles_32">OpenGL&trade; ES 3.2 API</h2>
496
497<p>Android N adds framework interfaces and platform support for OpenGL ES 3.2, including:</p>
498
499<ul>
500 <li> All extensions from the <a class="external-link"
501href="https://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">Android Extension Pack</a></a> (AEP) except for <code>EXT_texture_sRGB_decode</code>.
502 <li> Floating-point framebuffers for HDR and deferred shading.
503 <li> BaseVertex draw calls to enable better batching and streaming.
504 <li> Robust buffer access control to reduce WebGL overhead.
505</ul>
506
507<p>The framework API for OpenGL ES 3.2 on Android N is provided with the
508<code>GLES32</code> class. When using OpenGL ES 3.2, be sure to declare the
Andrew Solovay9b218572016-03-09 11:17:07 -0800509requirement in your manifest file, using the <code>&lt;uses-feature&gt;</code> tag and
Dirk Doughertycf65e4842016-03-07 22:31:57 -0800510the <code>android:glEsVersion</code> attribute. </p>
511
512<p>For information about using OpenGL ES, including how to check a device's
513supported OpenGL ES version at runtime, see the <a
514href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL ES API guide</a>.</p>
515
516
Dirk Dougherty59428922016-03-10 18:54:49 -0800517<h2 id="android_tv_recording">Android TV recording</h2>
518
519<p>Android N adds the ability to record and playback content from Android TV input
520services via new recording APIs. Building on top of existing time-shifting
521APIs, TV input services can control what channel data can be recorded, how
522recorded sessions are saved, and manage user interaction with recorded content. </p>
523
524<p>For more information, see <a
525href="{@docRoot}preview/features/tv-recording-api.html">Android TV Recording APIs</a>.</p>
526
527
528<h2 id="android_for_work">Android for Work</h2>
529
530<p>Android for Work adds many new features and APIs for devices running Android N.
Kevin Hufnagleb6d17232016-03-22 11:29:03 -0700531Some highlights are below &mdash; for a complete list of changes, see
532<a href="{@docRoot}preview/features/afw.html">Android for Work Updates</a>.</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800533
534<h3 id="work_profile_security_challenge">Work profile security challenge </h3>
535
536<p>
Andrew Solovay097b1152016-04-06 17:33:00 -0700537 Profile owners targeting the N SDK
538 can specify a separate security challenge for apps running in
Dirk Dougherty59428922016-03-10 18:54:49 -0800539 the work profile. The work challenge is shown when a user attempts to open
540 any work apps. Successful completion of the security challenge unlocks the
541 work profile and decrypts it if necessary. For profile owners,
542 <code>ACTION_SET_NEW_PASSWORD</code> prompts the user to set a work
543 challenge, and <code>ACTION_SET_NEW_PARENT_PROFILE_PASSWORD</code> prompts
544 the user to set a device lock.
545</p>
546
547<p>
Andrew Solovay097b1152016-04-06 17:33:00 -0700548 Profile owners can set distinct passcode policies for the work challenge
Dirk Dougherty59428922016-03-10 18:54:49 -0800549 (such as how long the PIN needs to be, or whether a fingerprint can be used
550 to unlock the profile) using the <code>setPasswordQuality()</code>,
551 <code>setPasswordMinimumLength()</code> and related methods. The profile
552 owner can also set the device lock using the <code>DevicePolicyManager</code>
553 instance returned by the new <code>getParentProfileInstance()</code> method.
554 Additionally, profile owners can customize the credentials screen for the
555 work challenge using the new <code>setOrganizationColor()</code> and
556 <code>setOrganizationName()</code> methods.
557</p>
558<h3 id="turn_off_work">Turn off work </h3>
559
560<p>On a device with a work profile, users can toggle work mode. When work mode is
561off the managed user is temporarily shut down, which disables work profile
562apps, background sync, and notifications. This includes the profile owner
563application. When work mode is off, the system displays a persistent status
564icon to remind the user that they can't launch work apps. The launcher
565indicates that work apps and widgets are not accessible. </p>
566
567<h3 id="always_on_vpn">Always on VPN </h3>
568
569<p>Device owners and profile owners can ensure that work apps always connect
570through a specified VPN. The system automatically starts that VPN after the
571device boots.</p>
572
573<p>
574 New <code>DevicePolicyManager</code> methods are
575 <code>setAlwaysOnVpnPackage()</code> and
576 <code>getAlwaysOnVpnPackage()</code>.
577</p>
578
579<p>Because VPN services can be bound directly by the system without app
580interaction, VPN clients need to handle new entry points for Always on VPN. As
581before, services are indicated to the system by an intent filter matching
582action <code>android.net.VpnService</code>. </p>
583
584<p>
585 Users can also manually set Always on VPN clients that implement
586 <code>VPNService</code> methods in the primary user using
587 <strong>Settings&gt;More&gt;Vpn</strong>.
588</p>
589
Andrew Solovay097b1152016-04-06 17:33:00 -0700590<h3 id="custom_provisioning">Customized provisioning</h3>
591
592<p>
593 An application can customize the profile owner and device owner provisioning
594 flows with corporate colors and logos.
595 <code>DevicePolicyManager.EXTRA_PROVISIONING_MAIN_COLOR</code> customizes
596 flow color. <code>DevicePolicyManager.EXTRA_PROVISIONING_LOGO_URI</code>
597 customizes the flow with a corporate logo.
598</p>
599
Dirk Dougherty59428922016-03-10 18:54:49 -0800600<h2 id="accessibility_enhancements">Accessibility enhancements</h2>
601
602<p>Android N now offers Vision Settings directly on the Welcome screen for new
603device setup. This makes it much easier for users to discover and configure
604accessibility features on their devices, including magnification gesture, font
605size, display size, and TalkBack. </p>
606
607<p>With these accessibility features getting more prominent placement, your users
608are more likely to try your app with them enabled. Make sure you test your apps
609early with these settings enabled. You can enable them from Settings >
610Accessibility.</p>
611
612<p>Also in Android N, accessibility services can now help users with motor
613impairments to touch the screen. The new API allows building services with
614features such as face-tracking, eye-tracking, point scanning, and so on, to
615meet the needs of those users.</p>
616
617<p>For more information, see <code>android.accessibilityservice.GestureDescription</code>
618 in the downloadable <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.</p>
619
620
621<h2 id="direct_boot">Direct boot</h2>
622
623<p>Direct boot improves device startup times and lets registered
624apps have limited functionality even after an unexpected reboot.
625For example, if an encrypted device reboots while the user is sleeping,
626registered alarms, messages and incoming calls can now continue notify
627the user as normal. This also means accessibility services can also be
628 available immediately after a restart.</p>
629
630<p>Direct boot takes advantage of file based encryption in Android N
631to enable fine grained encryption policies for both system and app data.
632The system uses a device-encrypted store for select system data and explicitly
633registered app data. By default a credential-encrypted store is used for all
634 other system data, user data, apps, and app data. </p>
635
636<p>At boot, the system starts in a restricted mode with access to
637device-encrypted data only, and without general access to apps or data.
638If you have components that you want to run in this mode, you can register
639them by setting a flag in the manifest. After restart, the system activates
640registered components by broadcasting the <code>LOCKED_BOOT_COMPLETED</code>
641intent. The system ensures registered device-encrypted app data is available
642before unlock. All other data is unavailable until the User confirms their lock
643 screen credentials to decrypt it. </p>
644
645For more information, see <a href="{@docRoot}preview/features/direct-boot.html">Direct Boot</a>.</p>
646</p>
647
648
649<h2 id="key_attestation">Key Attestation</h2>
650
651<p>Hardware-backed keystores provide a much safer method to create, store,
652and use cryptographic keys on Android devices. They protect keys from the
653Linux kernel, potential Android vulnerabilities, and extraction
654from rooted devices.</p>
655
656<p>To make it easier and more secure to use hardware-backed keystores,
657Android N introduces Key Attestation. Apps and off-devices can use Key
658Attestation to strongly determine whether an RSA or EC key pair is
659hardware-backed, what the properties of the key pair are, and what
660 constraints are applied to its usage and validity. </p>
661
662<p>Apps and off-device services can request information about a key pair
663through an X.509 attestation certificate which must be signed by a valid
664attestation key. The attestation key is an ECDSA signing key which is
665injected into the device’s hardware-backed keystore at the factory.
666Therefore, an attestation certificate signed by a valid attestation
667key confirms the existence of a hardware-backed keystore, along with
668 details of key pairs in that keystore.</p>
669
670<p>To ensure that the device is using a secure, official Android factory
671image, Key Attestation requires that the device <a
672class="external-link"
673href="https://source.android.com/security/verifiedboot/verified-boot.html#bootloader_requirements">bootloader</a>
674provide the following information to the <a class="external-link"
675href="https://source.android.com/security/trusty/index.html">Trusted
676Execution Environment (TEE)</a>:</p>
677
678<ul>
679<li>The OS version and patch level installed on the device</li>
680<li>The <a href="https://source.android.com/security/verifiedboot/index.html"
681class="external-link" >Verified Boot</a> public key and lock status</li>
682 </ul>
683
684<p>For more information about the hardware-backed keystore feature,
685see the guide for <a href="https://source.android.com/security/keystore/"
686class="external-link">Hardware-backed Keystore</a>.</p>
687
688<p>In addition to Key Attestation, Android N also introduces
689 fingerprint-bound keys that are not revoked on fingerprint enrollment.</p>
690
691<h2 id="network_security_config">Network Security Config</h2>
692
693<p>In Android N, apps can customize the behavior of their secure (HTTPS, TLS)
694connections safely, without any code modification, by using the declarative
695<em>Network Security Config</em> instead of using the conventional
696error-prone programmatic APIs (e.g. X509TrustManager).</p>
697
698 <p>Supported features:</p>
699<ul>
700<li><b>Custom trust anchors.</b> Lets an application customize which
701Certificate Authorities (CA) are trusted for its secure connections. For
702example, trusting particular self-signed certificates or a restricted set of public CAs.
703</li>
704<li><b>Debug-only overrides.</b> Lets an application developer safely debug
705secure connections of their application without added risk to the installed
706base.
707</li>
708<li><b>Cleartext traffic opt-out.</b> Lets an application protect itself from
709accidental usage of cleartext traffic.</li>
710<li><b>Certificate pinning.</b> An advanced feature that lets an application
711 limit which server keys are trusted for secure connections.</li>
712</ul>
713
714<p>For more information, see <a
715href="{@docRoot}preview/features/security-config.html">Network Security
716Config</a>.</p>
717
718<h2 id="default_trusted_ca">Default Trusted Certificate Authority</h2>
719
720<p>By default, apps that target Android N only trust system-provided certificates
721and no longer trust user-added Certificate Authorities (CA). Apps targeting Android
722N that wish to trust user-added CAs should use the
723<a href="{@docRoot}preview/features/security-config.html">Network Security Config</a> to
724specify how user CAs should be trusted.</p>
725
726<h2 id="apk_signature_v2">APK signature scheme v2</h2>
727
728<p>The PackageManager class now supports verifying apps using the APK
729signature scheme v2. The APK signature scheme v2 is a whole-file signature scheme
730that significantly improves verification speed and strengthens integrity
731 guarantees by detecting any unauthorized changes to APK files.</p>
732
733<p>To maintain backward-compatibility, an APK must be signed with the v1 signature
734scheme (JAR signature scheme) before being signed with the v2 signature scheme.
735With the v2 signature scheme, verification fails if you sign the APK with an
736 additional certificate after signing with the v2 scheme. </p>
737
738<p>APK signature scheme v2 support will be available later in the N Developer
739Preview.</p>
740
741<h2 id="scoped_directory_access">Scoped directory access</h2>
742
743<p>In Android N, apps can use new APIs to request access to specific <a
744href="{@docRoot}guide/topics/data/data-storage.html#filesExternal">external
745storage</a> directories, including directories on removable media such as SD
746cards. The new APIs greatly simplify how your application accesses standard
747external storage directories, such as the <code>Pictures</code> directory. Apps
748like photo apps can use these APIs instead of using
749<code>READ_EXTERNAL_STORAGE</code>, which grants access to all storage
750directories, or the Storage Access Framework, which makes the user navigate to
751the directory.</p>
752
753<p>Additionally, the new APIs simplify the steps a user takes to grant external
754storage access to your app. When you use the new APIs, the system uses a simple
755permissions UI that clearly details what directory the application is
756requesting access to.</p>
757
758<p>For more information, see the
759<a href="{@docRoot}preview/features/scoped-folder-access.html">Scoped
760Directory Access</a> developer documentation.</p>
761
Kevin Hufnagle93862ec2016-04-05 15:36:37 -0700762<h2 id="launcher_shortcuts">
763 Launcher shortcuts
764</h2>
Dirk Dougherty59428922016-03-10 18:54:49 -0800765
Kevin Hufnagle93862ec2016-04-05 15:36:37 -0700766<p>
767 Android N allows apps to define action-specific shortcuts which can be
768 displayed in the launcher. These <em>launcher shortcuts</em> let your users
769 quickly start common or recommended tasks within your app. Each shortcut
770 contains an <a href=
771 "{@docRoot}guide/components/intents-filters.html">intent</a>, which links the
772 shortcut to a specific action in your app. Examples of these actions include:
773</p>
Dirk Dougherty59428922016-03-10 18:54:49 -0800774
Kevin Hufnagle93862ec2016-04-05 15:36:37 -0700775<ul>
776 <li>Navigating users to a particular location in a mapping app.
777 </li>
Dirk Dougherty59428922016-03-10 18:54:49 -0800778
Kevin Hufnagle93862ec2016-04-05 15:36:37 -0700779 <li>Sending messages to a friend in a communication app.
780 </li>
Dirk Dougherty59428922016-03-10 18:54:49 -0800781
Kevin Hufnagle93862ec2016-04-05 15:36:37 -0700782 <li>Playing the next episode of a TV show in a media app.
783 </li>
Dirk Dougherty59428922016-03-10 18:54:49 -0800784
Kevin Hufnagle93862ec2016-04-05 15:36:37 -0700785 <li>Loading the last save point in a gaming app.
786 </li>
787</ul>
788
789<p>
790 Your app can create up to five <em>dynamic shortcuts</em>. When users perform
791 a gesture over your app's launcher icon, these shortcuts appear. By dragging
792 the shortcuts onto the launcher, users can make persistent copies of the
793 shortcuts, called <em>pinned shortcuts</em>. Users can create an unlimited
794 number of pinned shortcuts for each app.
795</p>
796
797<p class="note">
798 <strong>Note:</strong> Although other apps can't access your shortcut data,
799 the launcher <strong>does</strong> have access to this data. Therefore, the
800 shortcuts you create should conceal sensitive user information.
801</p>
802
803<p>
804 You can use this command to view your app's shortcuts:
805</p>
806
807<pre class="no-pretty-print">
808$ adb shell dumpsys shortcut
809</pre>
Andrew Solovay097b1152016-04-06 17:33:00 -0700810
Kevin Hufnagle93862ec2016-04-05 15:36:37 -0700811<p>
812 To update all shortcuts and to delete dynamic shortcuts, use the appropriate
813 methods that the Launcher Shortcut API provides. For more details about this
814 API, see <code>android.content.pm.ShortcutManager</code> in the downloadable
815 <a href="{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.
816</p>
Andrew Solovay097b1152016-04-06 17:33:00 -0700817
818<h2 id="print_svc">Print Service Enhancements</h2>
819
820<p>
821 In Android N, print service developers can now surface additional information
822 about individual printers and print jobs.
823</p>
824
825<p>
826 When listing individual printers, a print service can now set per-printer
827 icons in two ways:
828</p>
829
830<ul>
831 <li>You can set an icon from a resource ID by calling
832 <code>PrinterInfo.Builder.setResourceIconId()</code>
833 </li>
834
835 <li>You can show an icon from the network by calling
836 <code>PrinterInfo.Builder.setHasCustomPrinterIcon()</code>, and setting a
837 callback for when the icon is requested using
838 <code>android.printservice.PrinterDiscoverySession.onRequestCustomPrinterIcon()</code>
839 </li>
840</ul>
841
842<p>
843 In addition, you can provide a per-printer activity to display additional
844 information by calling <code>PrinterInfo.Builder.setInfoIntent()</code>.
845</p>
846
847<p>
848 You can indicate the progress and status of print jobs in the print job
849 notification by calling
850 <code>android.printservice.PrintJob.setProgress()</code> and
851 <code>android.printservice.PrintJob.setStatus()</code>, respectively.
852</p>
853
854<p>
855 For more information about these methods, see the downloadable <a href=
856 "{@docRoot}preview/setup-sdk.html#docs-dl">API Reference</a>.
857</p>
Eric Schmidt186fada2016-04-27 11:48:22 -0700858
859<h2 id="virtual_files">Virtual Files</h2>
860
861<p>
862 In previous versions of Android, your app could use the Storage Access
863 Framework to allow users to select files from their cloud storage accounts,
864 such as Google Drive. However, there was no way to represent files that did
865 not have a direct bytecode representation; every file was required to provide
866 an input stream.
867</p>
868
869<p>
870 Android N adds the concept of <em>virtual files</em> to the Storage Access
871 Framework. The virtual files feature allows your
872 {@link android.provider.DocumentsProvider} to return document URIs that can be
873 used with an {@link android.content.Intent#ACTION_VIEW} intent even if they
874 don't have a direct bytecode representation. Android N also allows you to
875 provide alternate formats for user files, virtual or otherwise.
876</p>
877
878<p>
879 To get a URI for a virtual document in your app, first you create an
880 {@link android.content.Intent} to open the file picker UI. Since an app
881 cannot directly open a virtual file by using the
882 {@link android.content.ContentResolver#openInputStream(Uri) openInputStream()}
883 method, your app does not receive any virtual files if you include the
884 {@link android.content.Intent#CATEGORY_OPENABLE} category.
885</p>
886
887<p>
888 After the user has made a selection, the system calls the
889 {@link android.app.Activity#onActivityResult onActivityResult()} method.
890 Your app can retrieve the URI of the virtual file and get an input stream, as
891 demonstrated in the code snippet below.
892</p>
893
894<pre>
895 // Other Activity code ...
896
897 final static private int REQUEST_CODE = 64;
898
899 // We listen to the OnActivityResult event to respond to the user's selection.
900 &#64;Override
901 public void onActivityResult(int requestCode, int resultCode,
902 Intent resultData) {
903 try {
904 if (requestCode == REQUEST_CODE &amp;&amp;
905 resultCode == Activity.RESULT_OK) {
906
907 Uri uri = null;
908
909 if (resultData != null) {
910 uri = resultData.getData();
911
912 ContentResolver resolver = getContentResolver();
913
914 // Before attempting to coerce a file into a MIME type,
915 // check to see what alternative MIME types are available to
916 // coerce this file into.
917 String[] streamTypes =
918 resolver.getStreamTypes(uri, "*/*");
919
920 AssetFileDescriptor descriptor =
921 resolver.openTypedAssetFileDescriptor(
922 uri,
923 streamTypes[0],
924 null);
925
926 // Retrieve a stream to the virtual file.
927 InputStream inputStream = descriptor.createInputStream();
928 }
929 }
930 } catch (Exception ex) {
931 Log.e("EXCEPTION", "ERROR: ", ex);
932 }
933 }
934</pre>
935
936<p>
937 For more information about accessing user files, see the
938 <a href="{@docRoot}guide/topics/providers/document-provider.html">Storage
939 Access Frameworks guide</a>.
Eric Schmidt12317682016-05-10 08:40:53 -0700940</p>
941
942<h2 id="emoji">New Emojis</h2>
943
944<p>
945 Android N introduces new emojis, including skin tone emojis, support
946 for variation
947 selectors, and other improvements. For a good user experience, observe the
948 following guidelines for using the new emojis and emoji features in your apps.
949</p>
950
951<ul>
952 <li>
953 <strong>New emojis</strong>: To check which emojis are present in the
954 system font, use the {@link android.graphics.Paint#hasGlyph(String)} method
955 and the dynamic layout in the emoji picker to place the glyphs.
956 </li>
957 <li>
958 <strong>Variation selectors</strong>: Variation selectors allow certain
959 emojis to be represented in color or in text presentation, which is used in
960 documents. For mobile devices, emojis should use their color representation.
961 To determine whether an emoji has a variation, use the variation selector.
962 You can view the complete list of characters with variations in the
963 <em>emoji variation sequences</em> section of the
964 <a href="http://www.unicode.org/Public/9.0.0/ucd/StandardizedVariants-9.0.0d1.txt">
965 Unicode documentation on variations</a>.
966 </li>
967 <li>
968 <strong>Skin tone modifiers</strong>: In Android N, users can modify the
969 rendered skin tone of emojis. This allows users to customize the presentation
970 of emojis to their preference. Keyboard apps should provide visual
971 indications for emojis that have multiple skin tones and should allow users to
972 select the skin tone that they prefer. To determine which system emojis have
973 skin tone modifiers, use the {@link android.graphics.Paint#hasGlyph(String)}
974 method. You can determine which emojis use skin tones by reading the
975 <a href="http://unicode.org/emoji/charts/full-emoji-list.html">
976 Unicode documentation</a>.
977 </li>
978</ul>