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