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