page.title=Android 6.0 Changes page.keywords=marshmallow,android60,sdk,compatibility meta.tags=marshmallow,api23,android60,androidm sdk.platform.apiLevel=23 page.image=images/cards/samples-new_2x.png @jd:body
Along with new features and capabilities, Android 6.0 (API level 23) includes a variety of system changes and API behavior changes. This document highlights some of the key changes that you should understand and account for in your apps.
If you have previously published an app for Android, be aware that these changes in the platform affect your app.
This release introduces a new permissions model, where users can now directly manage app permissions at runtime. This model gives users improved visibility and control over permissions, while streamlining the installation and auto-update processes for app developers. Users can grant or revoke permissions individually for installed apps.
On your apps that target Android 6.0 (API level 23) or higher, make sure to check for and request permissions at runtime. To determine if your app has been granted a permission, call the new {@link android.content.Context#checkSelfPermission(java.lang.String) checkSelfPermission()} method. To request a permission, call the new {@link android.app.Activity#requestPermissions(java.lang.String[], int) requestPermissions()} method. Even if your app is not targeting Android 6.0 (API level 23), you should test your app under the new permissions model.
For details on supporting the new permissions model in your app, see Working with System Permissions. For tips on how to assess the impact on your app, see Permissions Best Practices.
This release introduces new power-saving optimizations for idle devices and apps. These features affect all apps so make sure to test your apps in these new modes.
To learn more about these power-saving changes, see Optimizing for Doze and App Standby.
Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the {@link java.net.HttpURLConnection} class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your {@code build.gradle} file:
android { useLibrary 'org.apache.http.legacy' }
Android is moving away from OpenSSL to the BoringSSL library. If you’re using the Android NDK in your app, don't link against cryptographic libraries that are not a part of the NDK API, such as {@code libcrypto.so} and {@code libssl.so}. These libraries are not public APIs, and may change or break without notice across releases and devices. In addition, you may expose yourself to security vulnerabilities. Instead, modify your native code to call the Java cryptography APIs via JNI or to statically link against a cryptography library of your choice.
To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The {@link android.net.wifi.WifiInfo#getMacAddress() WifiInfo.getMacAddress()} and the {@link android.bluetooth.BluetoothAdapter#getAddress() BluetoothAdapter.getAddress()} methods now return a constant value of {@code 02:00:00:00:00:00}.
To access the hardware identifiers of nearby external devices via Bluetooth and Wi-Fi scans, your app must now have the {@link android.Manifest.permission#ACCESS_FINE_LOCATION} or {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} permissions:
Note: When a device running Android 6.0 (API level 23) initiates a background Wi-Fi or Bluetooth scan, the operation is visible to external devices as originating from a randomized MAC address.
This release removes the {@code Notification.setLatestEventInfo()} method. Use the {@link android.app.Notification.Builder} class instead to construct notifications. To update a notification repeatedly, reuse the {@link android.app.Notification.Builder} instance. Call the {@link android.app.Notification.Builder#build()} method to get updated {@link android.app.Notification} instances.
The {@code adb shell dumpsys notification} command no longer prints out your notification text. Use the {@code adb shell dumpsys notification --noredact} command instead to print out the text in a notification object.
Setting the volume directly or muting specific streams via the {@link android.media.AudioManager} class is no longer supported. The {@link android.media.AudioManager#setStreamSolo(int,boolean) setStreamSolo()} method is deprecated, and you should call the {@link android.media.AudioManager#requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, int, int) requestAudioFocus()} method instead. Similarly, the {@link android.media.AudioManager#setStreamMute(int,boolean) setStreamMute()} method is deprecated; instead, call the {@link android.media.AudioManager#adjustStreamVolume(int, int, int) adjustStreamVolume()} method and pass in the direction value {@link android.media.AudioManager#ADJUST_MUTE} or {@link android.media.AudioManager#ADJUST_UNMUTE}.
When users select text in your app, you can now display text selection actions such as Cut, Copy, and Paste in a floating toolbar. The user interaction implementation is similar to that for the contextual action bar, as described in Enabling the contextual action mode for individual views.
To implement a floating toolbar for text selection, make the following changes in your existing apps:
If you are using Android Support Library revision 22.2, be aware that floating toolbars are not backward-compatible and appcompat takes control over {@link android.view.ActionMode} objects by default. This prevents floating toolbars from being displayed. To enable {@link android.view.ActionMode} support in an {@link android.support.v7.app.AppCompatActivity}, call {@link android.support.v7.app.AppCompatActivity#getDelegate()}, then call {@link android.support.v7.app.AppCompatDelegate#setHandleNativeActionModesEnabled(boolean) setHandleNativeActionModesEnabled()} on the returned {@link android.support.v7.app.AppCompatDelegate} object and set the input parameter to {@code false}. This call returns control of {@link android.view.ActionMode} objects to the framework. In devices running Android 6.0 (API level 23), that allows the framework to support {@link android.support.v7.app.ActionBar} or floating toolbar modes, while on devices running Android 5.1 (API level 22) or lower, only the {@link android.support.v7.app.ActionBar} modes are supported.
This release removes support for global bookmarks. The {@code android.provider.Browser.getAllBookmarks()} and {@code android.provider.Browser.saveBookmark()} methods are now removed. Likewise, the {@code READ_HISTORY_BOOKMARKS} and {@code WRITE_HISTORY_BOOKMARKS} permissions are removed. If your app targets Android 6.0 (API level 23) or higher, don't access bookmarks from the global provider or use the bookmark permissions. Instead, your app should store bookmarks data internally.
With this release, the Android Keystore provider no longer supports DSA. ECDSA is still supported.
Keys which do not require encryption at rest will no longer be deleted when secure lock screen is disabled or reset (for example, by the user or a Device Administrator). Keys which require encryption at rest will be deleted during these events.
This release introduces the following behavior changes to the Wi-Fi and networking APIs.
In This release, the model for accessing shared resources in the camera service has been changed from the previous “first come, first serve” access model to an access model where high-priority processes are favored. Changes to the service behavior include:
The ART runtime now properly implements access rules for the {@link java.lang.reflect.Constructor#newInstance(java.lang.Object...) newInstance()} method. This change fixes a problem where Dalvik was checking access rules incorrectly in previous versions. If your app uses the {@link java.lang.reflect.Constructor#newInstance(java.lang.Object...) newInstance()} method and you want to override access checks, call the {@link java.lang.reflect.Constructor#setAccessible(boolean) setAccessible()} method with the input parameter set to {@code true}. If your app uses the v7 appcompat library or the v7 recyclerview library, you must update your app to use to the latest versions of these libraries. Otherwise, make sure that any custom classes referenced from XML are updated so that their class constructors are accessible.
This release updates the behavior of the dynamic linker. The dynamic linker now understands the difference between a library’s {@code soname} and its path ( public bug 6670), and search by {@code soname} is now implemented. Apps which previously worked that have bad {@code DT_NEEDED} entries (usually absolute paths on the build machine’s file system) may fail when loaded.
The {@code dlopen(3) RTLD_LOCAL} flag is now correctly implemented. Note that {@code RTLD_LOCAL} is the default, so calls to {@code dlopen(3)} that didn’t explicitly use {@code RTLD_LOCAL} will be affected (unless your app explicitly used {@code RTLD_GLOBAL}). With {@code RTLD_LOCAL}, symbols will not be made available to libraries loaded by later calls to {@code dlopen(3)} (as opposed to being referenced by {@code DT_NEEDED} entries).
On previous versions of Android, if your app requested the system to load a shared library with text relocations, the system displayed a warning but still allowed the library to be loaded. Beginning in this release, the system rejects this library if your app's target SDK version is 23 or higher. To help you detect if a library failed to load, your app should log the {@code dlopen(3)} failure, and include the problem description text that the {@code dlerror(3)} call returns. To learn more about handling text relocations, see this guide.
The platform now performs stricter validation of APKs. An APK is considered corrupt if a file is declared in the manifest but not present in the APK itself. An APK must be re-signed if any of the contents are removed.
Device connections through the USB port are now set to charge-only mode by default. To access the device and its content over a USB connection, users must explicitly grant permission for such interactions. If your app supports user interactions with the device over a USB port, take into consideration that the interaction must be explicitly enabled.
This release includes the following behavior changes for Android for Work:
EXTRA_PROVISIONING_RESET_PROTECTION_PARAMETERS
is removed so NFC bump
provisioning cannot programmatically unlock a factory reset protected device.BLUETOOTH_ON
DEVELOPMENT_SETTINGS_ENABLED
MODE_RINGER
NETWORK_PREFERENCE
WIFI_ON