Android 6.0 new features and major API changes

Source: Internet
Author: User
Tags deprecated

With new features and functionality, Android 6.0 (API level 23) brings a series of changes to the system and API behavior. This article will cover some of the major change points that need to be understood and noted in the application.

If you have previously published Android apps, be aware of the impact these changes have on your application.

Run-time permissions

The new permission model is introduced in this release, and users can now manage the permissions of the application directly at run time. This model is based on more visibility of the user's permissions control, while providing a smoother application installation and automatic upgrade for application developers. Users can grant or cancel permissions independently for each application that is installed.

In applications running on the target version of Android 6.0 (API level 23) and above, permissions must be checked and requested at run time. Use a new checkSelfPermission() method to determine whether your application has been authorized. The new method is used requestPermissions() to request permissions. Even if your application is running a target version other than Android 6.0 (API level 23), you should also test the application under the new licensing model.

For more details on supporting the new permissions model in your application, you can view the use of system permissions. How to use permissions in your application, tips to view permissions best practices.

Hibernation and app hangs (Doze and app Standby)

This release introduces power-saving optimizations for idle devices and applications. This feature affects all applications, so make sure your application is tested in these new modes.

    • Hibernate : If the user pulls the device down and resets it, the screen is turned off, and after a while the device enters sleep mode. At this point, the device tries to keep the system in a state of sleep. In this mode, the device periodically resumes normal operations so that the application synchronizes, and the system can handle some delayed operations.

    • app hangs : App suspend allows the system to be defined as idle when the user is no longer using the application. The system can make this decision when the user has not touched the application for a period of time. When the device is unplugged, the system disables network access, stops the synchronization and operation of the application, and is considered idle.

Learn more about power-saving changes and see optimizations for hibernation and app hangs.

Removing Apache HTTP Clients

The Android 6.0 release removes support for Apache HTTP clients. If your application uses this client, and the target is running version Android 2.3 (API level 9) and above, you need to use a HttpURLConnection class instead. This API is more efficient because it reduces network overhead and minimizes power consumption by transparently compressing the user, responding to the cache. To continue using Apache HTTP APIs, you need to build.gradle declare the following compile-time dependencies in the file:

1
2
3
Android {
' Org.apache.http.legacy '
}
Boringssl

Android moved from OpenSSL to the Boringssl library. If you use the Android NDK in your application, do not link the crypto library to any libraries other than the NDK API, such as libcrypto.so and libssl.so . These libraries are not public APIs and may be changed or interrupted between the release and the device without being notified. In this case you will expose yourself to security threats. You should modify your local code to invoke the Java encryption API via JNI or statically link a cryptographic library of your choice.

Access Hardware identifiers

In order to give users more data protection, from this version, Android removes the use of WiFi and Bluetooth APIs to programmatically access local hardware identifiers in the application. WifiInfo.getMacAddress()both now and BluetoothAdapter.getAddress() the method will return 02:00:00:00:00:00 constants.

To access hardware identifiers for nearby external devices via Bluetooth and WiFi scanning, application needs ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions:

    • WifiManager.getScanResults())
    • BluetoothDevice.ACTION_FOUND
    • BluetoothLeScanner.startScan())

Note: When a device that is running Android 6.0 (API level 23) Initializes a WiFi or Bluetooth scan in the background, the operation is visible to the external device and is given a random MAC address.

Notice

This version removes the Notification.setLatestEventInfo() method. Use the Notification.builder class instead of the construction method. To repeat the update notification, reuse the Notification.builder instance. Call the Build () method to get the updated Notification instance.

adb shell dumpsys nnotificationThe command is not in the consent notification text. Use adb shell dumpsys notification --noredcat the command to print text in a gay object.

Audiomanager Change

Using the Audiomanager class to set the volume directly or mute the stream is no longer supported. The Setstreamsolo () method is deprecated and you need to call Requestaudiofocus () instead. Similarly, the Setstreammute () method is deprecated, replaced with the Adjuststreamvolume () method, and passes the direction value Adjust_mute or Adjust_unmute.

Text selection

When the user selects text in the application, you can display text selection work in the hover toolbar, such as Cut, copy, and paste. The user interaction implementation is similar to the context Action Bar described in launch context action mode for standalone views.

To implement the hover toolbar for text selection, you need to make the following modifications in an existing application:

    1. In the View or Activity object, startActionMode(Callback) change the actionmode by modifying it startActionMode(Callback, ActionMode.TYPE_FLOATING) .

    2. To inherit an existing ActionMode.Callback implementation from Actionmode.callback2.

    3. The overloaded Ongetcontentrect () method provides the coordinates of the content Rect object (such as a text selection rectangle) in the view.

    4. If the rectangle position is not valid and this is the only element that needs to be refreshed, call the Invalidatecontentrect () method.

If you are using the Android 22.2 Revision Compatibility Pack, the hover toolbar is not backwards compatible and uses the default Actionmode object. This causes the Hover toolbar to not display. Enable Actionmode in appcompatactivity, call Getdelegate () first, and then call in the returned Appcompatdelegate object Sethandlenativeactionmodesenabled (), and set the input parameter to false . This call returns a controllable Actionmode object for the framework. On devices running Android 6.0 (API level 23), this allows the framework to support ActionBar or hover toolbar mode. On Android 5.1 (API level 22) or earlier, only ActionBar is supported.

Browser Bookmark Changes

This version removes the support for global bookmarks. android.provider.Browser.getAllBookmark()and the android.provider.Browser.saveBookmark() method is removed. The same, READ_HISTORY_BOOKMARKS and WRITE_HISTORY_BOOKMARKS permissions are removed. If your application has a target run version of Android 6.0 (API level 23) or higher, do not access bookmarks from global providers or use bookmark permissions. Your application now needs to save the bookmark data internally.

Android Keystore Changes

In this version, the Android Keystore provider is not in support of DSA. ECDSA is still supported.

When the security lock screen is disabled or reset, the key that does not require encryption will no longer be deleted. Keys that require encryption are deleted in these events.

Wi-Fi and network changes

This version introduces the following behavior changes for Wi-Fi and network APIs:

    • Applications can notconsistent the state of these objects only after they have been created with wificonfiguration objects. When Wificonfiguration is created by a user or other application, you will not be allowed to modify and delete these Wificonfiguration objects.
    • In previous releases, if the application was using Enablenetwork () and was set disableAllOthers=true to force the device to connect to the specified Wi-Fi network, the device would be disconnected from the other network. In this release, these devices will no longer be disconnected from other networks. If the application targetSdkVersion is 20 or lower, the selected Wi-Fi network is connected. If the application targetSdkVersion is 21 or higher, use a multi-network API (such as OpenConnection (), Bindsocket (), and the New Bindprocesstonetwork () method) to ensure that its network traffic is sent to the selected network.
Camera Service Changes

In this version, the mode of accessing shared resources in the camera service has changed, no longer the previous "first come, first served", but high priority will be given priority. Changes in service behavior include:

    • Access to the camera subsystem's resources, including opening and configuring the camera device, depends on the priority of the client application process. Application processes that are visible to the user or active in the foreground tend to have higher priority, making the camera resource more accessible and reliable.

    • Active camera client applications with low permissions may be interrupted when higher-priority application views use the camera. In the deprecated Camera API, the error is called in the OnError () of the interrupted client. In the Camera2 API, the error result is called in ondisconnected ().

    • On devices that have the right camera hardware, different application processes can open and use separate camera devices independently at the same time. Even so, when multi-process is used, accessing the camera at the same time can cause a sharp decline in device performance, which will be detected by the camera service is not allowed. This change makes it possible for clients that are interrupted due to a lower priority to try to access the same device even when no other application is directly accessible.

    • Changing the current user will cause the camera client to be interrupted by the activity in the previous user account's application. Access to the camera is limited by the current device user. In fact, this means that when the user switches to a different account, the camera subsystem used by the original "guest" account will not be able to continue running.

Run-time

The ART runtime through the Newinstance () method now correctly implements the access rules. This change fixes an error in previous versions when Dalvik checked access rules. If your application uses the Newinstance () method, and you want to overwrite the access check, call Setaccessible () handy and set the parameter to true . If your application uses the V7 Compatibility Library and the V7 Recyclerview library. You need to upgrade the relevant libraries in your application to the latest version. Otherwise, you need to make sure that the custom class referenced in the XML has been upgraded and its construction method is accessible.

This version upgrades the behavior of the dynamic linker. The dynamic connector can now understand the soname difference between the library and its path, and it implements the soname search through. At load time, previously available applications may be prompted to have an unavailable DT_NEEDED entry (typically an absolute path in the build Machine file system).

dlopen(3) RTLD_LOCALThe logo is now properly implemented. RTLD_LOCALis the default, so calls dlopen(3) are not explicitly used to RTLD_LOCAL be valid (unless explicitly used before the app RTLD_GLOBAL ). RTLD_LOCAL, the tag dlopen(3) is not available before the call loads the library (this is the DT_NEEDED opposite of the entry reference).

In previous versions of Android, if your app requested the system to load a dynamic-link library containing text relocation segments, the system would display a warning, but allow the library to continue loading. Starting with this version, if your target is running SDK version 23 or above, the system will reject the library. To help detect whether the library was successfully loaded, the application needs to add a log for the dlopen(3) failure and dlerror(3) include the description text of the problem in the return value. Learn more about how to work with text relocation segments to view this guide.

APK Authentication

The Android platform now performs more rigorous APK validation. If a file is declared in the manifest file but not in the APK, then this apk is considered invalid. If any of the content is removed, the APK needs to be re-signed.

USB Connection

Device connection via USB port is now set to charging mode by default. To access the device and its contents via a USB connection, the user needs to provide explicit authorization for these interactions. If your application enables users to interact with the device over a USB port, you need to ensure that these interactions are explicitly enabled.

Android for work change

This version includes the following changes to the Android for work behavior:

  • the contact person in the personal context . Google Dialer Call history can now display the current contact when a user views a call record. setCrossProfileCallerIdDisabled()hide the current contact by setting it in Google dialer true . When set setBluetoothContactSharingDisabled() to false , the current contact can be displayed in the device contact via Bluetooth. By default, it is set to true .

  • Remove Wi-Fi configuration : A Wi-Fi configuration that is added by an external owner (such as through the Addnetworkd () method) is now removed when the current profile is deleted.

  • closed Wi-Fi configuration : If WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN it is not empty, any Wi-Fi configuration created by the active device owner will not be able to be modified and deleted by the user. Users can create and modify their own Wi-Fi configuration. The active device owner has privileges to edit and remove any Wi-Fi configuration, including configurations that are not created by them.

  • download using the policy controller via Google account : When a Google account that requires a WPC application to be managed is added to a device outside the admin context, the Add account process prompts the user to install the appropriate WPC. These behaviors can also be applied to accounts added by setting up > Accounts in the initial Device Creation wizard.

  • Develop Devicepolicymanager API behavior changes :

    • Invokes setCameraDisabled() a method to affect the current calling user's webcam.
    • In addition, the setKeyguardDisabledFeatures() method is available to profile users, as is the case with the device owner.
    • The profile owner can set the constraint on the keyboard guard:
      • Keyguard_disable_trust_agents and Keyguard_disable_fingerprint will affect the keyboard guard settings of the profile parent user.
      • Keyguard_disable_unredacted_notifications only affects notifications generated by the application in profile.
    • The Createandinitializeuser () and CreateUser () methods have been deprecated.
    • When a given user's application is running in the foreground, the setscreencapturedisabled () method blocks the secondary structure.
    • The default value for SHA-256 is extra_provisioning_device_admin_package_checksum. To maintain compatibility, SHA-1 is still supported, but will be removed in the future. The Extra_provisioning_device_admin_signature_checksum only accepts SHA-256.
    • The original device initialization API has been removed from Android 6.0 (API level 23).
    • The extra_provisioning_reset_protection_parameters is removed, so the NFC bump PROVISIONING cannot be programmatically unlocked to reset the protected device.
    • Extra_provisioning_admin_extras_bundle can now be used by NFC in managed devices to pass data to the device owner's application.
    • The Android for work API on Android M is optimized, including work configuration, helper layer and other. The new Devicepolicymanager permissions API does not affect previous versions of Android apps.
    • When the user returns from the synchronization part of the creation process through action_provision_managed_profile or action_provision_managed_device intent, the system returns result_canceled The result code.
  • Other API changes :

    • Data usage: android.app.usage.NetworkUsageStates class renamed to Networkstats.
  • Global Settings Change :
    • The following settings cannot continue to be set through the Setglobalsettings () method:
      • BLUETOOTH_ON
      • DEVELOPMENT_SETTINGS_ENABLED
      • MODE_RINGER
      • NETWORK_PREFERENCE
      • WIFI_ON
    • The following global settings can be set through the Setglobalsettings () method:
      • Wifi_device_owner_configs_lockdown

Android 6.0 new features and major API changes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.