Android N Development Everything you need to know

Source: Internet
Author: User
Tags cas billing cycle java jdk 8

Reprint Please specify source: http://blog.csdn.net/lowprofile_coding/article/details/51331123

First, preface

If you have good English advice to visit the official website, the bottom of the official website also has the translation language choice.
Website address: http://developer.android.com/preview/api-overview.html#android_for_work

Of course all the premise is that your computer can access the external network .... Celestial you know .... The wit of me so early to prepare you for the circumvention tool.
Window version download: Link: http://pan.baidu.com/s/1kVIWhin Password: qwuf
Mac version download: Link: http://pan.baidu.com/s/1qYzPef6 Password: hg88

If you don't want to be so troublesome, look at my translated version ....

Second, about Android N program

Android N Preview runs March 9, 2016 and is scheduled for the third quarter of 2016. A total of 5 preview version, under normal circumstances, 4-6 weeks to update a preview version, now the second preview version has been updated.

In the first three previews Google offers a test and development environment where you can find out your app's compatibility with Android N systems. Just run your app on Android n system to see if it's incompatible, Android n the system has any bugs you can also with Google company feedback.

In preview version 4 and 5, you can get the final API and SDK, as well as the final system image, this time provide the standard API, you can do the application compatibility final Test, as well as optimization, also can add the latest API.

Third, the development of Android N

Development process: Update Android studio2.1-> update android N sdk-> update jdk8-> Update your Andorid project--Call new API
Test flow: Have a androidn phone--Install your app-> test your app

1). Update Android Studio2.1
Android N added support for java8, need to call a name is Jack's compiler, Jack's latest version is currently only supported by Android Studio2.1 version, if you want to use Java 8 language features, you need to use Android Studio 2.1 Develop your application, if you do not need JDK8 features, but you want to use the Android N SDK, you still need to update jdk8 to compile.

If you have installed Android studio but the version is 2.1 below click Help > Check for update to update to version 2.1.
If you don't have Android studio installed at all, point me to download

2). Get Android N Preview SDK
To use Android N API for development, you need to install Android N Preview SDK into Android studio.

See this picture should know how to download it, the specific steps I omitted.

3). Get Android N Preview reference documentation
N-preview-2-docs.zip

4). Get JDK 8
For Android Studio 2.1 to edit Android N version of the app, you need to install JDK 8, if you are not JDK 8, download the update yourself.
Then set the JDK version in Android studio as follows:
-Open the Android project in studio Android and then open the Project Structure dialog box by selecting File > Project Structure. (Alternatively, you can choose to set the default File > Other Settings for all projects > Default Project Structure).
-In the left pane of the dialog box, click the SDK location.
-In the JDK location field, enter the location of Java JDK 8 (click the button to the right of your file) and click OK.

5). Update or create a project
Using the Android N API development, your project must be adapted.
If you plan to use Java 8 features, you should also read Java 8 about supported features and how to configure your project information with the Jack compiler.

Update an existing project
Open the Build.gradle file under module and make the following updates:

android {   ‘android-N‘   ‘24.0.0-rc3‘   ...   defaultConfig {      ‘N‘      ‘N‘      ...   }   ... }

Create a new project
To develop a new project with the Android N Preview SDK:
-click File > New Project. Follow the steps to keep going and stay on the Android device Selection screen.
-On this screen, you can choose your phone and tablet.
-Select N:android API 23,n Preview (preview) in the list of minimum SDK options on phone and tablet

Iv. new features of Android n 1. Multi-Window Support

In Android N, we have introduced a new and much needed multitasking feature for the platform-multi-window support.

Users can now open two apps on the screen at a time.

    • On phones and tablets running Android N, users can run two apps side-by-side or in Split-screen mode when one app is on top of another. Users can adjust the app by dragging a divider between the two apps.
    • On Android TV devices, apps can put themselves in picture mode, allowing them to continue to display content as users browse or interact with other apps. For more information, see below.

Multi-window support gives you new ways to engage users, especially on tablets and other larger screens. You can even enable drag-and-drop in your app to make it easy for users to drag and drop content into your app or drag content from it-this is a great way to enhance the user experience.

Adding Multi-window support to your app and configuring multi-window display processing is straightforward. For example, you can specify the minimum size allowed by your activity, which prevents users from adjusting the activity below that size. You can also disable Multi-window display for your app, which ensures that the app is only displayed in full-screen mode.

For more information, please refer to the Multi-window support developer documentation.

2.Notification Enhanced Features

In Android N, we redesigned the notification to make it easier to use and faster. Some of these changes include:
-Template update: We are updating the notification template with new emphasis on pictures and avatars. Developers will be able to make full use of the new template with minimal code adjustments.
-Notification of bindings: The system can group messages together (for example, by message subject) and display groups. The user can do the Dismiss or Archive appropriately. If you've implemented notifications for Android Wear, you're already familiar with this model.
-Direct response: For real-time communication applications, the Android system supports inline replies so that users can quickly reply to text messages directly in the notification interface.
-Custom Views: Two new APIs allow you to take advantage of the style of your system, such as notification titles and actions, when you use custom views in notifications.

For information about how to implement new features, see the Notification Guide.

2. Configuration file Guidance for JIT/AOT compilation

In Android N, we added the Just in time (JIT) compiler to code analysis of ART so that it can continue to improve the performance of Android apps while the app is running. The JIT compiler complements the current Ahead of Time (AOT) compiler for Android running components to help improve runtime performance, save storage space, and speed application updates and system updates.

The compilation of profile guidance allows Android to run components to manage the Aot/jit compilation of each application based on the actual use of the app and the situation on the device. For example, the Android runtime component maintains a configuration file for each application's hot method, and can precompile and cache these methods for optimal performance. For other parts of the app, it will not compile until it is actually used.

In addition to improving the performance of key parts of your application, the compilation of profile guidance helps reduce the overall RAM footprint, including associated binaries. This feature is especially important for low memory devices.

The Android runtime component minimizes the impact on the device battery when it manages the compilation of profile guidance. Compiling only when the device is idle and charging allows you to save time and power by doing the work in advance.

3. Fast Application Installation path

One of the most practical benefits of the JIT compiler for running components on Android is the speed of application installation and system updates. Even large applications that require a few minutes of optimization and installation in Android 6.0 can now be installed in just a few seconds. System updates also become faster because of the elimination of optimization steps.

4. Snooze Mode

Android 6.0 introduced snooze mode, which is when the device is idle, by delaying the application's CPU and network activity to achieve power-saving system mode, for example, when the device is placed on a table or drawer.

Now, in Android N, snooze mode is a step forward and can save power while out. As long as the screen is off for a while and the device is not plugged in, Doze mode uses familiar CPU and network restrictions for the app. This means that users can save power even if they put the device in their pocket.

After the screen shuts down for a moment, when the device is using the battery, doze mode restricts network access while delaying jobs and syncing. After a short period of maintenance, it allows the application to access the network and perform deferred job/synchronization. Turning on the screen or plugging the device into power causes the device to exit Doze mode.

When the device is still at rest, the screen turns off and uses the battery for a period of time, and the NAP mode applies full CPU and network limits for Powermanager.wakelock, Alarmmanager alerts, and GPS/WI-FI scans.

The best practice for adjusting the app to doze mode is the same regardless of whether the device is in motion, so if you've updated your app to properly handle doze mode, everything is ready. If not, start adjusting the app to snooze mode immediately.

5.Project svelte: Background optimization

Project svelte is continuously improving to minimize the RAM used by systems and applications in a range of Android devices in the ecosystem. In Android N, Project svelte focuses on optimizing how apps are run in the background.

Background processing is an important part of most applications. Handled properly, it allows you to achieve a great user experience-instant, fast, and situational awareness. If not handled properly, background processing consumes RAM (and batteries) unnecessarily, while affecting the system performance of other applications.

Since Android 5.0 was released, Jobscheduler has become the preferred way to perform back-office work in a way that is beneficial to users. Apps can schedule jobs while allowing the system to be optimized based on memory, power, and connection conditions. Jobscheduler allows for control and simplicity, and we want all applications to use it.

Another very good option is Gcmnetworkmanager (part of the Google Play Service), which offers similar job scheduling and compatibility in older versions of Android.

We are continuing to extend Jobscheduler and gcmnetworkmanager to conform to multiple use cases-for example, in Android N, you can now schedule background work based on changes in the content provider. At the same time, we are beginning to discard some older patterns that degrade system performance, especially for low-memory devices.

In Android N, we removed three commonly used implicit broadcasts-connectivity_action, action_new_picture, and action_new_video-because these broadcasts might wake up a background process for multiple apps at once. Both memory and battery are exhausted. If your app receives these broadcasts, make the most of N Developer Preview to migrate to Jobscheduler and related APIs.

For more information, please see the background optimization document.

6.Data Saver

The cost of a cellular data plan typically exceeds the cost of the device itself over the life cycle of a mobile device. For many users, cellular data is the expensive resource they want to save.

Android N introduces the data Saver mode, a new system service that helps reduce cellular data used by applications, whether roaming, the end of the billing cycle, or the use of a small amount of prepaid packets. Data Saver allows users to control how applications use cellular data, while allowing developers to open data Saver to provide more effective services.

When users enable data Saver in Settings and the device is on a metered network, the system masks the use of background data and instructs the app to use as little data as possible in the foreground-for example, by limiting the bitrate for streaming media services, reducing image quality, and delaying the best pre-buffering. Users can whitelist specific apps to allow background data to be used by traffic, even when opening data Saver.

Android N inherits the Connectivitymanager to provide a way for the app to retrieve the user's Data Saver preferences and monitor the preference changes. All apps should check if the user has data Saver enabled and try to limit the use of foreground and background data.

7. Quickly set up the tile API

Quick Setup is typically used to display key settings and actions directly from the notification bar, which is very simple. In Android N, we've expanded the range of "quick settings" to make it more useful and convenient.

We added more space for the extra "quick setup" tile, which allows users to access them by swiping left or right across the display area of the pagination. We also let users control which "quick settings" tiles are displayed and where they are displayed-users can drag and drop tiles to add or move tiles.

For developers, Android N also adds a new API that allows you to define your own "Quick settings" Tile, giving users easy access to key controls and actions in your app.

For controls and actions that are needed or frequently used, leave the quick settings Tile and should not be used as a shortcut to launch the app.

After you define tiles, you can display them to users, and users can add tiles to the quick settings by dragging and dropping them.

For more information on creating app tiles, see Android.service.quicksettings.Tile in the downloadable API reference.

8. Number Masking

Android N now supports number masking in the platform, providing a framework API that allows service providers to maintain a list of blocked numbers. The default SMS app, default phone app, and provider app can read and write to a masked list of numbers. Other apps will not be able to access this list.

By making the number screen a standard feature of the platform, Android provides a consistent way for applications to support number masking on a wide range of devices. Other benefits that your app can take advantage of include:
-also block text messages from blocked call numbers
-shielded numbers can be reserved across resets and devices through the Backup & Restore feature
-Multiple apps can use the same masked number list

In addition, the carrier application integration via Android means that the operator can read a list of blocked numbers on the device and perform a service-side masking for the user to prevent unwanted calls and text messages from reaching the user through any medium, such as a VOIP endpoint or a forwarded phone.

For more information, see Android.provider.BlockedNumberContract in the downloadable API reference.

9. Incoming Call filtering

Android N allows the default phone app to filter incoming calls. The mobile app does this by implementing a new Callscreeningservice that allows the phone app to perform a number of operations based on the call-call.details, such as:
-Refusal of incoming calls
-Incoming call logs are not allowed
-No call notifications are displayed to the user

For more information, see Android.telecom.CallScreeningService in the downloadable API reference.

10. Multi-locale support, multi-language

Android N now allows users to select multiple locales in the settings to better support bilingual use cases. Apps can use the new API to get the locale that the user chooses, and then provide a more sophisticated user experience for multi-locale users-such as displaying search results in multiple languages and not translating pages in a language that the user understands.

In addition to multi-locale support, Android N also expands the range of languages available to users. It provides more than 25 variants for common languages, such as English, Spanish, French, and Arabic. It also adds a subset of support for more than 100 new languages.

The app can get a list of locale settings that the user sets by calling Localelist.getdefault (). To support the number of locales that are extended, Android N is changing the way it parses resources. Be sure to use the new resource resolution logic to test and verify that your app is running as expected.

For more information about the new resource resolution behavior and best practices to follow, see multilingual support.

the icu4j API in 11.Android

Android N currently provides a subset of the icu4j API in the Android framework (under the ANDROID.ICU software package). Migration is simple, and it is primarily necessary to change from the Com.java.icu namespace to Android.icu. If you've already used the icu4j bundle in your app, switching to the ANDROID.ICU API provided in the Android framework can save a lot of APK size.

If you want more information about the Android icu4j API, see icu4j Support.

12.OpenGL? ES 3.2 API

Android N adds a framework interface and platform support for OpenGL ES 3.2, including:
-All extensions (except Ext_texture_srgb_decode) from the Android expansion pack (AEP).
-floating-point frame buffering and lazy coloring for HDR.
-Basevertex drawing calls for better batch processing and streaming services.
-Powerful buffer access control to reduce WebGL overhead.

The framework API for OpenGL ES 3.2 on Android N is provided with the GLES32 class. When using OpenGL ES 3.2, be sure to declare the requirements in your manifest file through the tag and Android:glesversion properties.

For information about using OpenGL ES, including how to check the OpenGL ES version supported by your device at run time, see the OpenGL ES API Guide.

13.Android TV Recording

Android N adds the ability to record and play content from the Android TV input service with the new recording API. Built on top of an existing time-lapse API, the TV input service can control how channel data can be recorded, save recorded sessions, and manage user interaction through recorded content.

For more information, see the Android TV recording API.

14.Android for work

Android for Works adds a number of new features and APIs to devices running Android N. Some of the important things are as follows-for a complete list of Android for work updates related to Android N, see Android for work changes.

15. Close the work

On a device that has a managed profile, the user can switch the operating mode. When working mode is turned off, the managed user temporarily shuts down, which disables the managed profile app, background synchronization, and notifications. This includes the configuration file owner app. When you turn off working mode, the system displays a permanent status icon to remind users that they cannot start the work app. The launcher indicates that the work app and widgets are inaccessible.

16.Always on VPN

The device owner and profile owner can ensure that the work app always passes through the specified VPN connection. The system starts the VPN automatically after the device starts.

The new Devicepolicymanager methods are Setalwaysonvpnpackage () and Getalwaysonvpnpackage ().

Because the VPN service can be directly bound by the system without application interaction, the VPN client must handle the new entry point for always on VPN. As before, the service is instructed to the system by the Intent filter that matches the operation. Android.net.VpnService.

Users can also use Settings>more>vpn to manually set the always on VPN client that implements the Vpnservice method in the primary user.

17. Auxiliary Tool Enhancements

Android N now offers "Vision Settings" directly on the Welcome screen for new device settings. This makes it easier for users to discover and configure accessibility features on their devices, including magnification gestures, font size, display size, and TalkBack.

As these accessibility features become more prominent, your users are more likely to try your app when these features are enabled. Be sure to enable these settings in advance to test your app. You can enable them through Settings > accessibility.

Or in Android N, the accessibility service can now help users with motion-impaired touch the screen. The new API allows the use of features such as face tracking, eye tracking, and point scanning to build services to meet the needs of these users.

For more information, see Android.accessibilityservice.GestureDescription in the downloadable API reference

18. Direct Start

Direct start-up reduces device startup time and allows registered apps to have limited functionality, even after an unexpected restart. For example, if the encrypted device restarts when the user sleeps, the registered alerts, messages, and calls can now continue to notify the user as usual. This also means that the post-boot accessibility service is immediately available.

In Android N, direct startup takes full advantage of file-based encryption to enable granular encryption policies for system and application data. For system and application data. The system uses device-encrypted storage for selected system data and for application data that is explicitly registered. By default, credential-encrypted storage is available for all other system data, user data, apps, and application data.

At startup, the system starts in a restricted mode, accessing only the data encrypted by the device, without general access to the app or data. If you have components that you want to run in this mode, you can register them by setting tags in the manifest file. After rebooting, the system activates the registered components by broadcasting locked_boot_completed Intent. The system ensures that the registered device encrypted application data is available before unlocking. All other data is not available until the user confirms that the lock screen credentials are decrypted.

For more information, see Direct boot.

19. Key authentication

Using a hardware-backed keystore, you can more securely create, store, and use encryption keys on your Android device. They protect the key from the Linux kernel, potential Android vulnerabilities, and can prevent the key from being extracted from the rooted device.

To make the hardware-backed KeyStore easier and more secure to use, Android N introduces key authentication. Application and shutdown devices can use key authentication to determine resolutely whether the RSA or EC key pair is subject to hardware support, the properties of the key pair, and the limitations of its use and effectiveness.

The application and shutdown device Services can request information about the key pair through the certificate of authentication (which must be signed by a valid authentication key). The authentication key is a ECDSA signing key, which is injected into the device's hardware-backed KeyStore at the factory. Therefore, a valid authentication key-signed certificate confirms the existence of a hardware-supported keystore and the details of the key pair in the KeyStore.

To ensure that the device uses a secure, official Android factory image, key authentication requires that the device bootloader provide the following information to the trusted execution Environment (TEE):

    • Operating system version and patch level installed on the device
    • Verify the startup public key and lock state.

For more information about the key library features supported by hardware, see the hardware-supported KeyStore guide.

In addition to key authentication, Android N also introduces a fingerprint binding key that will not be revoked when the fingerprint is registered.

20. Network Security Configuration

In Android N, an app can safely customize its secure (HTTPS, TLS) connection behavior without any code modification by using a descriptive network security configuration instead of using traditional, error-prone programming APIs (for example, X509trustmanager).

Supported Features:

    • Custom Trust anchors. Let apps customize which certification authorities (CAs) are trusted for their secure connections. For example, trust a specific self-signed certificate or a restricted set of public CAs.
    • Debug overrides only. Enables application developers to securely debug their application's secure connections without increasing the risk of installation fundamentals.
    • Clear text flow exits. Let your app prevent you from accidentally using clear text traffic.
    • Fixed certificate. This is an advanced feature that allows apps to restrict which server keys are trusted for secure connections.
      For more information, see Network Security Configuration.
21. Default trusted certification Authority

By default, apps for Android N Trust only the certificates provided by the system, and the certification authority (CA) that the user adds is no longer trusted. If an app for Android N wants to trust a user-added CA, you should use a network security configuration to specify how to trust the user ca.

22.APK Signature Scheme v2

The Packagemanager class now supports the use of the APK signature Scheme v2 authentication app. APK Signature Scheme v2 is an entire file signing architecture that allows you to significantly increase the speed of verification by detecting any unauthorized changes to the APK file, while also enhancing integrity assurance.

To maintain backward compatibility, the APK must be signed with the V1 signature schema (JAR signature schema) before signing with the V2 signature schema. For the V2 signature schema, validation will fail if the APK is signed with an additional certificate after signing with the V2 schema.

APK Signature Scheme v2 support will be available later in N Developer preview.

23. Scope Directory Access

In Android N, apps can use the new API to request access to specific external storage directories, including directories on removable media, such as SD cards. The new API greatly simplifies the way applications access standard external storage directories, such as the Pictures directory. Apps, such as photo apps, can use these APIs (instead of using read_external_storage), which grants access to all storage directories or the storage access framework, allowing users to navigate to the directory.

In addition, the new API simplifies the steps for users to grant external storage access to the app. When you use the new API, the system uses a simple permissions UI that clearly details the directory that the app is requesting access to.

For more information, see the scope Directory Access developer documentation.

Crossing if you think the article is good, help a praise it, for you is a little effort, but for me this is the motivation to persist.

If you want the first time to read our late article, sweep code attention to the public, the weekly not regularly push the Android development of practical tutorial articles, you also wait for what, quickly pay attention to it, learn technology, as CEO, win white rich beauty ....

      Android开发666 - 安卓开发技术分享            扫描二维码加关注

Android N Development Everything you need to know

Related Article

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.