Home | History | Annotate | Download | only in versions
      1 page.title=Android 5.0 Behavior Changes
      2 excludeFromSuggestions=true
      3 sdk.platform.version=5.0
      4 sdk.platform.apiLevel=21
      5 @jd:body
      6 
      7 <!-- video box -->
      8 
      9 <div id="qv-wrapper">
     10 <div id="qv">
     11 
     12 <h2>In this document</h2>
     13 
     14 <ol id="toc44" class="hide-nested">
     15   <li><a href="#UI"><a href="#ART">ART Runtime</a></a></li>
     16   <li><a href="#BehaviorNotifications">Notifications</a></li>
     17   <li><a href="#BehaviorMediaControl">Media Controls</a></li>
     18   <li><a href="#BehaviorGetRecentTasks">getRecentTasks()</a></li>
     19   <li><a href="#64BitSupport">64-Bit Android NDK</a></li>
     20   <li><a href="#BindService">Binding to a Service</a></li>
     21   <li><a href="#Power"><a href="#BehaviorWebView">WebView</a></a></li>
     22   <li><a href="#custom_permissions">Custom Permissions</a></li>
     23   <li><a href="#ssl">TLS/SSL Configuration</a></li>
     24   <li><a href="#managed_profiles">Support for Managed Profiles</a></li>
     25 </ol>
     26 
     27 <h2>API Differences</h2>
     28 <ol>
     29 <li><a href="{@docRoot}sdk/api_diff/21/changes.html">API level 20 to 21 &raquo;</a> </li>
     30 <li><a href="{@docRoot}sdk/api_diff/preview-21/changes.html">L Developer Preview to 21 &raquo;</a> </li>
     31 </ol>
     32 
     33 
     34 <h2>See Also</h2>
     35 <ol>
     36 <li><a href="{@docRoot}about/versions/lollipop.html">Android Lollipop Highlights</a> </li>
     37 <li><a href="{@docRoot}about/versions/android-5.0.html">Android 5.0 API Overview</a> </li>
     38 </ol>
     39 
     40 
     41 </div>
     42 </div>
     43 
     44 <a class="notice-developers-video" href="https://www.youtube.com/watch?v=um1S2u022HA">
     45 <div>
     46     <h3>Video</h3>
     47     <p>Dev Byte: What's New in Android 5.0</p>
     48 </div>
     49 </a>
     50 
     51 <a class="notice-developers-video" href="https://www.youtube.com/watch?v=Uiq2kZ2JHVY">
     52 <div>
     53     <h3>Video</h3>
     54     <p>Dev Byte: Notifications</p>
     55 </div>
     56 </a>
     57 
     58 <p>API Level: {@sdkPlatformApiLevel}</p>
     59 <p>Along with new features and capabilities, Android 5.0 includes a variety of
     60 system changes and API behavior changes. This document highlights
     61 some of the key changes that you should be understand and account for in your apps.</p>
     62 
     63 <p>If you have previously published an app for Android, be aware that your app
     64   might be affected by these changes in Android 5.0.</p>
     65 
     66 
     67 <p>For a high-level look at the new platform features, instead
     68 see the
     69 <a href="{@docRoot}about/versions/lollipop.html">Android Lollipop
     70 highlights</a>.</p>
     71 
     72 
     73 
     74 <h2 id="ART">Android Runtime (ART)</h2>
     75 
     76 <p>In Android 5.0 the ART runtime replaces Dalvik as the platform default. The ART runtime was
     77 introduced in Android 4.4 on an experimental basis.</p>
     78 
     79 <p>For an overview of ART's new features, see
     80 <a href="https://source.android.com/devices/tech/dalvik/art.html">Introducing
     81 ART</a>. Some of the major new features are:</p>
     82 
     83 <ul>
     84   <li>Ahead-of-time (AOT) compilation</li>
     85   <li>Improved garbage collection (GC)</li>
     86   <li>Improved debugging support</li>
     87 </ul>
     88 
     89 <p>Most Android apps should just work without any changes under ART. However, some
     90 techniques that work on Dalvik do not work on ART. For information about the
     91 most important issues, see
     92 <a href="{@docRoot}guide/practices/verifying-apps-art.html">Verifying App
     93 Behavior on the Android Runtime (ART)</a>. Pay particular attention if:</p>
     94 
     95 <ul>
     96   <li>Your app uses Java Native Interface (JNI) to run C/C++ code.</li>
     97   <li>You use development tools that generate non-standard code (such as some
     98       obfuscators).</li>
     99   <li>You use techniques that are incompatible with compacting garbage
    100       collection.</li>
    101 </ul>
    102 
    103 
    104 <h2 id="BehaviorNotifications">Notifications</h2>
    105 
    106 <p>Make sure your notifications take these Android 5.0 changes into account.
    107  To learn more about designing your notifications for Android 5.0 and higher,
    108  see the <a
    109  href="https://material.google.com/patterns/notifications.html">notifications
    110  design guide</a>.
    111 </p>
    112 
    113 <h3 id="NotificationsMaterialDesignStyle">Material design style</h3>
    114 <p>Notifications are drawn with dark text atop white (or very light) backgrounds
    115   to match the new material design widgets. Make sure that all your
    116   notifications look right with the new color scheme. If your notifications
    117 look wrong, fix them:</p>
    118 
    119 <ul>
    120   <li>Use {@link android.app.Notification.Builder#setColor(int) setColor()}
    121     to set an accent color in a circle behind your icon image. </li>
    122   <li>Update or remove assets that involve color. The system ignores all
    123     non-alpha channels in action icons and in the main notification icon. You
    124     should assume that these icons will be alpha-only. The system draws
    125     notification icons in white and action icons in dark gray.</li>
    126 </ul>
    127 
    128 <h3 id="NotificationsSoundVibration">Sound and vibration</h3>
    129 <p>If you are currently adding sounds and vibrations to your notifications by
    130 using the {@link android.media.Ringtone}, {@link android.media.MediaPlayer},
    131 or {@link android.os.Vibrator} classes, remove this code so that
    132 the system can present notifications correctly in
    133 <em>priority</em> mode. Instead, use
    134 {@link android.app.Notification.Builder} methods to add sounds and
    135 vibration.</p>
    136 
    137 <p>Setting the device to
    138 {@link android.media.AudioManager#RINGER_MODE_SILENT RINGER_MODE_SILENT} causes
    139 the device to enter the new priority mode. The device leaves priority
    140 mode if you set it to
    141 {@link android.media.AudioManager#RINGER_MODE_NORMAL RINGER_MODE_NORMAL} or
    142 {@link android.media.AudioManager#RINGER_MODE_NORMAL RINGER_MODE_VIBRATE}.</p>
    143 
    144 <p>Previously, Android used {@link android.media.AudioManager#STREAM_MUSIC STREAM_MUSIC}
    145 as the master stream to control volume on tablet devices. In Android 5.0, the
    146 master volume stream for both phone and tablet devices is now unified, and
    147 is controlled by {@link android.media.AudioManager#STREAM_RING STREAM_RING} or
    148 {@link android.media.AudioManager#STREAM_NOTIFICATION STREAM_NOTIFICATION}.</p>
    149 
    150 <h3 id="NotificationsLockscreenVisibility">Lock screen visibility</h3>
    151 <p>By default, notifications now appear on the user's lock screen in Android 5.0.
    152 Users can choose to protect sensitive information from being exposed, in which
    153 case the system automatically redacts the text displayed by the notification. To
    154 customize this redacted notification, use
    155 {@link android.app.Notification.Builder#setPublicVersion(android.app.Notification)
    156   setPublicVersion()}.</p>
    157 <p>If the notification does not contain personal information, or if you want to
    158 allow media playback control on the notification, call the
    159 {@link android.app.Notification.Builder#setVisibility(int) setVisibility()}
    160 method and set the notification's visibility level to
    161 {@link android.app.Notification#VISIBILITY_PUBLIC VISIBILITY_PUBLIC}.
    162 </p>
    163 
    164 <h3 id="NotificationsMediaPlayback">Media playback</h3>
    165 <p>If you are implementing notifications that present media playback
    166 status or transport controls, consider using the new
    167 {@link android.app.Notification.MediaStyle} template instead of a custom
    168 {@link android.widget.RemoteViews.RemoteView} object. Whichever approach you
    169 choose, make sure to set the notification's visibility to
    170 {@link android.app.Notification#VISIBILITY_PUBLIC VISIBILITY_PUBLIC} so that
    171 your controls are accessible from the lock screen. Note that beginning in
    172 Android 5.0, the system no longer shows
    173 {@link android.media.RemoteControlClient} objects on the lock screen. For more
    174 information, see
    175 <a href="#BehaviorMediaControl">If your app uses RemoteControlClient</a>.</p>
    176 
    177 <h3 id="NotificationsHeadsup">Heads-up notification</h3>
    178 <p>Notifications may now appear in a small floating window (also called a
    179   heads-up notification) when the device is active (that is, the device is
    180   unlocked and its screen is on). These notifications appear similar to the
    181   compact form of your notification, except that the heads-up notification also
    182   shows action buttons. Users can act on, or dismiss, a heads-up notification
    183   without leaving the current app.</p>
    184 
    185 <p>Examples of conditions that may trigger heads-up notifications include:</p>
    186 
    187 <ul>
    188   <li>The user's activity is in fullscreen mode (the app uses
    189 {@link android.app.Notification#fullScreenIntent})</li>
    190   <li>The notification has high priority and uses ringtones or vibrations</li>
    191 </ul>
    192 
    193 <p>If your app implements notifications under any of those scenarios, make sure
    194 that heads-up notifications are presented correctly.</p>
    195 
    196 <h2 id="BehaviorMediaControl">Media Controls and RemoteControlClient</h2>
    197 <p>The {@link android.media.RemoteControlClient} class is now deprecated. Switch
    198   to the new {@link android.media.session.MediaSession} API as
    199   soon as possible.</p>
    200 
    201 <p>Lock screens in Android 5.0 do not show transport controls for
    202 your {@link android.media.session.MediaSession} or
    203 {@link android.media.RemoteControlClient}. Instead, your app can provide
    204 media playback control from the lock screen through a notification. This
    205 gives your app more control over the presentation of media buttons, while
    206 providing a consistent experience for users across locked and
    207 unlocked devices.</p>
    208 
    209 <p>Android 5.0 introduces a new
    210 {@link android.app.Notification.MediaStyle} template for this purpose.
    211 {@link android.app.Notification.MediaStyle} converts notification
    212 actions that you added with
    213 {@link android.app.Notification.Builder#addAction(int, java.lang.CharSequence,
    214   android.app.PendingIntent)
    215 Notification.Builder.addAction()} into compact buttons embedded in your app's
    216 media playback notifications. Pass your session token to the
    217 {@link android.app.Notification.MediaStyle#setMediaSession(android.media.session.MediaSession.Token)
    218   setSession()} method to inform the system that this notification controls an
    219   ongoing media session.</p>
    220 
    221 <p>Make sure to set the notification's visibility to
    222   {@link android.app.Notification#VISIBILITY_PUBLIC VISIBILITY_PUBLIC}
    223   to mark the notification as safe to show on any lock screen (secure or
    224   otherwise). For more information, see
    225   <a href="#LockscreenNotifications">Lock screen notifications</a>.</p>
    226 
    227 <p>To display media playback controls if your app is running on the
    228 Android <a href="{@docRoot}tv/index.html">TV</a> or
    229 <a href="{@docRoot}wear/index.html">Wear</a> platform, implement the
    230 {@link android.media.session.MediaSession} class. You should also implement
    231 {@link android.media.session.MediaSession} if your app needs to receive media
    232 button events on Android devices.</p>
    233 
    234 <h2 id="BehaviorGetRecentTasks">getRecentTasks()</h2>
    235 
    236 <p>With the introduction of the new <em>concurrent documents and activities
    237 tasks</em> feature in Android 5.0 (see <a href="#Recents">Concurrent
    238 documents and activities in the recents screen</a> below),
    239 the {@link android.app.ActivityManager#getRecentTasks
    240 ActivityManager.getRecentTasks()} method is now deprecated to improve user
    241 privacy. For backward compatibility, this method still returns a small subset of
    242 its data, including the calling applications own tasks and possibly some other
    243 non-sensitive tasks (such as Home). If your app is using this method to retrieve
    244 its own tasks, use {@link android.app.ActivityManager#getAppTasks() getAppTasks()}
    245 instead to retrieve that information.</p>
    246 
    247 <h2 id="64BitSupport">64-Bit Support in the Android NDK</h2>
    248 
    249 <p>Android 5.0 introduces support for 64-bit systems. The 64-bit enhancement
    250   increases address space and improves performance, while still supporting
    251   existing 32-bit apps fully. The 64-bit support also improves the performance of
    252   OpenSSL for cryptography. In addition, this release introduces new native
    253   media NDK APIs, as well as native OpenGL ES (GLES) 3.1 support.</p>
    254 
    255 <p>To use the 64-bit support provided in Android 5.0, download and install NDK
    256   Revision 10c from the
    257 <a href="{@docRoot}tools/sdk/ndk/index.html">Android NDK page</a>. Refer to the
    258 Revision 10c <a href="{@docRoot}tools/sdk/ndk/index.html#Revisions">release notes</a>
    259 for more information about important changes and bug fixes to the NDK.</p>
    260 
    261 <h2 id="BindService">Binding to a Service</h2>
    262 
    263 <p>The
    264   {@link android.content.Context#bindService(android.content.Intent, android.content.ServiceConnection, int) Context.bindService()}
    265   method now requires an explicit {@link android.content.Intent},
    266 and throws an exception if given an implicit intent.
    267 To ensure your app is secure, use an explicit intent when starting or binding
    268 your {@link android.app.Service}, and do not declare intent filters for the service.</p>
    269 
    270 <h2 id="BehaviorWebView">WebView</h2>
    271 
    272 <p>Android 5.0 changes the default behavior for your app.</p>
    273 <ul>
    274 <li><strong>If your app targets API level 21 or higher:</strong>
    275   <ul>
    276     <li>The system
    277   blocks <a href="https://developer.mozilla.org/en-US/docs/Security/MixedContent"
    278   class="external-link">mixed content</a> and third party cookies by default. To allow mixed
    279   content and third party cookies, use the
    280   {@link android.webkit.WebSettings#setMixedContentMode(int) setMixedContentMode()}
    281 and {@link android.webkit.CookieManager#setAcceptThirdPartyCookies(android.webkit.WebView, boolean) setAcceptThirdPartyCookies()}
    282 methods respectively.</li>
    283     <li>The system now intelligently chooses portions of the HTML
    284       document to draw. This new default behavior helps to reduce memory
    285       footprint and increase performance. If you want to
    286       render the whole document at once, disable this optimization by calling
    287       {@link android.webkit.WebView#enableSlowWholeDocumentDraw()}.</li>
    288   </ul>
    289 </li>
    290 <li><strong>If your app targets API levels lower than 21:</strong> The system
    291   allows mixed content and third party cookies, and always renders the whole
    292   document at once.</li>
    293 </ul>
    294 
    295 <h2 id="custom_permissions">Uniqueness Requirement for Custom Permissions</h2>
    296 
    297 <p>
    298   As documented in the <a href=
    299   "{@docRoot}guide/topics/manifest/manifest-intro.html#perms">Permissions</a>
    300   overview, Android apps can define custom permissions as a means of managing
    301   access to components in a proprietary way, without using the platforms
    302   pre-defined system permissions. Apps define custom permissions in <a href=
    303   "http://developer.android.com/guide/topics/manifest/permission-element.html"><code>
    304   &lt;permission&gt;</code></a> elements declared in their manifest files.
    305 </p>
    306 
    307 <p>
    308   There are a small number of scenarios where defining custom permissions is a
    309   legitimate and secure approach. However, creating custom permissions is
    310   sometimes unnecessary and can even introduce potential risk to an app,
    311   depending on the protection level assigned to the permissions.
    312 </p>
    313 
    314 <p>
    315   Android 5.0 includes a behavior change to ensure
    316   that only one app can define a given custom permission, unless signed with the
    317   same key as other apps defining the permission.
    318 </p>
    319 
    320 <h3>
    321   Apps using duplicate custom permissions
    322 </h3>
    323 
    324 <p>
    325   Any app can define any custom permission it wants, so it can happen
    326   that multiple apps might <strong>define the same custom permission</strong>.
    327   For example, if two apps offer a similar capability, they might derive the
    328   same logical name for their custom permissions. Apps might also incorporate
    329   common public libraries or code examples that themselves include the same
    330   custom permission definitions.
    331 </p>
    332 
    333 <p>
    334   In Android 4.4 and earlier, users were able to install multiple such
    335   apps on a given device, although the system assigned the protection level
    336   specified by the first-installed app.
    337 </p>
    338 
    339 <p>
    340   Starting in Android 5.0, the system enforces a new
    341   <strong>uniqueness restriction on custom permissions</strong> for
    342   apps that are signed with different keys. Now only one app on a device can
    343   define a given custom permission (as determined by its name), unless the
    344   other app defining the permission is signed with the same key. If the user
    345   tries to install an app with a duplicate custom permission and is not signed
    346   with the same key as the resident app that defines the permission, the system
    347   blocks the installation.
    348 </p>
    349 
    350 <h3>
    351   Considerations for your app
    352 </h3>
    353 
    354 <p>
    355   In Android 5.0 and later, apps can continue to define their own custom
    356   permissions just as before and to request custom permissions from other apps
    357   through the <code>&lt;uses-permission&gt;</code> mechanism. However with the
    358   new requirement introduced in Android 5.0, you should carefully assess
    359   possible impacts on your app.
    360 </p>
    361 
    362 <p>
    363   Here are some points to consider:
    364 </p>
    365 
    366 <ul>
    367   <li>Does your app declare any <a href=
    368   "http://developer.android.com/guide/topics/manifest/permission-element.html">
    369     <code>&lt;permission&gt;</code></a> elements in its manifest? If so, are
    370     they actually necessary to the proper function of your app or service? Or
    371     could you use a system default permission instead?
    372   </li>
    373 
    374   <li>If you have <a href=
    375   "http://developer.android.com/guide/topics/manifest/permission-element.html">
    376     <code>&lt;permission&gt;</code></a> elements in your app, do you know where
    377     they came from?
    378   </li>
    379 
    380   <li>Do you actually intend for other apps to request your custom permissions
    381   through <a href=
    382   "http://developer.android.com/guide/topics/manifest/uses-permission-element.html">
    383     <code>&lt;uses-permission&gt;</code></a>?
    384   </li>
    385 
    386   <li>Are you using boilerplate or example code in your app that includes
    387   <a href=
    388   "http://developer.android.com/guide/topics/manifest/permission-element.html">
    389     <code>&lt;permission&gt;</code></a> elements? Are those permission elements
    390     actually necessary?
    391   </li>
    392 
    393   <li>Do your custom permissions use names that are simple or based on common
    394   terms that other apps might share?
    395   </li>
    396 </ul>
    397 
    398 <h3>
    399   New installs and updates
    400 </h3>
    401 
    402 <p>
    403   As mentioned above, for new installs and updates of your app on devices
    404   running Android 4.4 or earlier are unaffected and there is no change in
    405   behavior. For new installs and updates on devices running Android 5.0 or
    406   later, the system <strong>prevents installation of your app</strong> if it
    407   defines a custom permission that is already defined by an existing resident
    408   app.
    409 </p>
    410 
    411 <h3>
    412   Existing installs with Android 5.0 system update
    413 </h3>
    414 
    415 <p>
    416   If your app uses custom permissions and is widely distributed and installed,
    417   theres a chance that it will be affected when users receive update their
    418   devices to Android 5.0. After the system update is installed, the system
    419   revalidates installed apps, including a check of their custom permissions. If
    420   your app defines a custom permission that is already defined by another app
    421   that has already been validated, and your app is not signed with the same key
    422   as the other app, the system <strong>does not re-install your app</strong>.
    423 </p>
    424 
    425 <h3>
    426   Recommendations
    427 </h3>
    428 
    429 <p>
    430   On devices running Android 5.0 or later, we recommend that you examine your
    431   app immediately, make any adjustments needed, and publish the updated version
    432   as soon as possible to your users.
    433 </p>
    434 
    435 <ul>
    436   <li>If you are using custom permissions in your app, consider their origin
    437   and whether you actually need them. Remove all <a href=
    438   "http://developer.android.com/guide/topics/manifest/permission-element.html">
    439     <code>&lt;permission&gt;</code></a> elements from your app, unless you are
    440     certain that they are required for proper function of your app.
    441   </li>
    442 
    443   <li>Consider replacing your custom permissions with system default
    444   permissions where possible.
    445   </li>
    446 
    447   <li>If your app requires custom permissions, rename your custom permissions
    448   to be unique to your app, such as by appending them to the full package name
    449   of your app.
    450   </li>
    451 
    452   <li>If you have a suite of apps <em>signed with different keys</em> and the apps
    453   access a shared component by means of a custom permission, make sure that the
    454   custom permission is only defined once, in the shared component. Apps that
    455   use the shared component should not define the custom permission themselves,
    456   but should instead request access through the <a href=
    457   "{@docRoot}guide/topics/manifest/uses-permission-element.html">
    458     <code>&lt;uses-permission&gt;</code></a> mechanism.
    459   </li>
    460 
    461   <li>If you have a suite of apps are <em>signed with the same key</em>,
    462   each app can define the same custom permission(s) as <span style="white-space:nowrap;">needed
    463   &mdash; the</span> system allows the apps to be installed in the usual way.
    464   </li>
    465 
    466 </ul>
    467 
    468 
    469 <h2 id="ssl">
    470   TLS/SSL Default Configuration Changes
    471 </h2>
    472 
    473 <p>
    474   Android 5.0 introduces changes the default TLS/SSL configuration used by apps
    475   for HTTPS and other TLS/SSL traffic:
    476 </p>
    477 
    478 <ul>
    479   <li>TLSv1.2 and TLSv1.1 protocols are now enabled,</li>
    480   <li>AES-GCM (AEAD) cipher suites are now enabled,</li>
    481   <li>MD5, 3DES, export, and static key ECDH cipher suites are now disabled,</li>
    482   <li>Forward Secrecy cipher suites (ECDHE and DHE) are preferred.</li>
    483 </ul>
    484 
    485 <p>
    486   These changes may lead to breakages in HTTPS or TLS/SSL connectivity in a
    487   small number of cases listed below.
    488 </p>
    489 
    490 <p>
    491   Note that the security ProviderInstaller from Google Play services already
    492   offers these changes across Android platform versions back to Android 2.3.
    493 </p>
    494 
    495 <h3>
    496   Server does not support any of the enabled ciphers suites
    497 </h3>
    498 
    499 <p>
    500   For example, a server might support only 3DES or MD5 cipher suites. The
    501   preferred fix is to improve the servers configuration to enable stronger and
    502   more modern cipher suites and protocols. Ideally, TLSv1.2 and AES-GCM should
    503   be enabled, and Forward Secrecy cipher suites (ECDHE, DHE) should be enabled
    504   and preferred.
    505 </p>
    506 
    507 <p>
    508   An alternative is to modify the app to use a custom SSLSocketFactory to
    509   communicate with the server. The factory should be designed to create
    510   SSLSocket instances which have some of the cipher suites required by the
    511   server enabled in addition to default cipher suites.
    512 </p>
    513 
    514 <h3>
    515   App is making wrong assumptions about cipher suites used to connect to server
    516 </h3>
    517 
    518 <p>
    519   For example, some apps contain a custom X509TrustManager that breaks because
    520   it expects the authType parameter to be RSA but encounters ECDHE_RSA or
    521   DHE_RSA.
    522 </p>
    523 
    524 <h3>
    525   Server is intolerant to TLSv1.1, TLSv1.2 or new TLS extensions
    526 </h3>
    527 
    528 <p>
    529   For example, the TLS/SSL handshake with a server is erroneously rejected or
    530   stalls. The preferred fix is to upgrade the server to comply with the TLS/SSL
    531   protocol. This will make the server successfully negotiate these newer
    532   protocols or negotiate TLSv1 or older protocols and ignore TLS extensions it
    533   does not understand. In some cases disabling TLSv1.1 and TLSv1.2 on the
    534   server may work as a stopgap measure until the server software is upgraded.
    535 </p>
    536 
    537 <p>
    538   An alternative is to modify the app to use a custom SSLSocketFactory to
    539   communicate with the server. The factory should be designed to create
    540   SSLSocket instances with only those protocols enabled which are correctly
    541   supported by the server.
    542 </p>
    543 
    544 <h2 id="managed_profiles">Support for Managed Profiles</h2>
    545 
    546 <p>
    547   Device administrators can add a <em>managed profile</em> to a device. This
    548   profile is owned by the administrator, giving the administrator control
    549   over the managed profile while leaving the user's personal profile, and its
    550   storage space, under the user's control.
    551   This change can affect the behavior of your existing app in
    552   the following ways.</p>
    553 
    554 <h3 id="mg_profile_intents">Handling intents</h3>
    555 
    556 <p>Device administrators can restrict access to system applications from the
    557 managed profile. In this case, if an app fires an intent from the managed
    558 profile that would ordinarily be handled by that application, and there is no
    559 suitable handler for the intent on the managed profile,
    560 the intent causes an exception. For example, the
    561 device administrator can restrict apps on the managed profile from accessing
    562 the system's camera application. If your app is running on the managed profile
    563 and calls {@link
    564 android.app.Activity#startActivityForResult startActivityForResult()} for {@link
    565 android.provider.MediaStore#ACTION_IMAGE_CAPTURE
    566 MediaStore.ACTION_IMAGE_CAPTURE}, and there is no app on the managed profile
    567 that can handle the intent, this results in an {@link
    568 android.content.ActivityNotFoundException}.</p>
    569 
    570 <p>You can prevent this by checking
    571 that there is at least one handler for any intent
    572 before firing it. To check for a valid handler, call {@link
    573 android.content.Intent#resolveActivity Intent.resolveActivity()}. You can see
    574 an example of this being done in <a
    575 href="{@docRoot}training/camera/photobasics.html#TaskCaptureIntent">Take Photos
    576 Simply: Take a Photo with the Camera App</a>.</p>
    577 
    578 <h3 id="mp_profile_file_sharing">Sharing files across profiles</h3>
    579 
    580 <p>Each profile has its own file storage. Since a file URI refers to a specific
    581 location in the file storage, this means that a file URI that is valid on one
    582 profile is not valid on the other one. This is not ordinarily a problem for an
    583 app, which usually just accesses the files it creates. However, if an app
    584 attaches a file to an intent, it is not safe to attach a file URI, since in some
    585 circumstances, the intent might be handled on the other profile.
    586 For example, a device administrator might specify that image capture events
    587 should be handled by the camera app on the personal profile. If the intent is
    588 fired by an app on the managed profile, the camera needs to be able to write the
    589 image to a location where the managed profile's apps can read it.</p>
    590 
    591 <p>To be safe, when
    592 you need to attach a file to an intent that might cross from one profile to the
    593 other, you should create and use a <em>content URI</em> for the file. For more
    594 information about sharing files with content URIs, see <a
    595 href="{@docRoot}training/secure-file-sharing/index.html">Sharing Files</a>.
    596 For example, the device administrator might whitelist {@link
    597 android.provider.MediaStore#ACTION_IMAGE_CAPTURE ACTION_IMAGE_CAPTURE} to be
    598 handled by the camera in the personal profile. The firing intent's {@link
    599 android.provider.MediaStore#EXTRA_OUTPUT EXTRA_OUTPUT} should contain a content
    600 URI specifying where the photo should be stored. The camera app can write the
    601 image to the location specified by that URI, and the app that fired the intent
    602 would be able to read that file, even if the app is on the other profile. </p>
    603 
    604 <h3>Lockscreen widget support removed</h3>
    605 
    606 <p>Android 5.0 removes support for lockscreen widgets; it continues to support
    607 widgets on the home screen.</p>