Android 8.1 Developer Preview

Preview · Android - Bởi Google

· 25/10/2017 16:38 (7 năm trước)

Giới Thiệu · Android 8.1 Developer Preview

Android O introduces a variety of new features and capabilities for users and developers. This document highlights what's new for developers.

Make sure to check out Android O Behavior Changes to learn about areas where platform changes may affect your apps.

Neural networks API

The Neural Networks API (NNAPI) provides apps with hardware acceleration for on-device machine learning operations. The API supports on- device model creation, compilation, and execution. Apps typically do not use NNAPI directly; instead, NNAPI is meant to be called by machine learning libraries, frameworks, and tools that let developers train their models and deploy them on Android devices.

To learn more about the Neural Networks API, see the Neural Networks API reference docs and the Neural Networks API developer guide.

Notifications

Android 8.1 Developer Preview 1 includes the following changes to notifications:

  • Apps can now only make a notification alert sound once per second. Alert sounds that exceed this rate aren't queued and are lost. This change doesn't affect other aspects of notification behavior and notification messages still post as expected.
  • NotificationListenerService and ConditionProviderService are not supported on low-ram Android-powered devices that return true whenActivityManager.isLowRamDevice() is called.

Improved targeting for low-RAM devices

Android 8.1 (API level 27) adds two new hardware-feature constants, FEATURE_RAM_LOW and FEATURE_RAM_NORMAL, to Package Manager. These constants allow you target the distribution of your apps and APK splits to normal- or low-RAM devices.

These constants enable the Play store to promote a better user experience by highlighting apps especially well-suited to the capabilities of a given device.

Autofill framework updates

Android 8.1 Developer Preview (API level 27) provides several improvements to the Autofill Framework that you can incorporate into your apps.

The Developer Preview adds support for custom descriptions that the Android System shows in the autofill save UI instead of the original representation of the data. This is useful, for example, when you want to mask a credit card number and show only the last four digits. To learn more, see the CustomDescription class.

The Developer Preview allows you to specify a Validator object that your app can use to decide if the Android System should show the autofill save UI. This functionality is provided by the setValidator() method of the SaveInfo.Builder class.

The BaseAdapter class in the Developer Preview includes the setAutofillOptions() method, which allows you to provide string representations of the values in an adapter. This is useful for spinner controls that dynamically generate the values in their adapters. For example, you can use thesetAutofillOptions() method to provide a string representation of the list of years that the users can choose as part of a credit card expiration date. Autofill services can use the string representation to appropriately fill out the views that require the data.

Additionally, the AutofillManager class includes the notifyViewVisibilityChanged(View, int, boolean) method that you can call to notify the framework about changes in the visibility of a view in a virtual structure. There's also an overload of the method for non virtual structures. However, non virtual structures usually don't require you to explicitly notify the framework because the method is already called by the View class.

EditText update

Beginning with API level 27, the EditText.getText() method returns an Editable; previously it returned a CharSequence. This change is backward-compatible, as Editable implements CharSequence.

The Editable interface provides valuable additional functionality. For example, because Editable also implements the Spannable interface, you can apply markup to content within an instance of EditText.

Programmatic Safe Browsing actions

By using the WebView implementation of the Safe Browsing API, your app can detect when an instance of WebView attempts to navigate to a URL that Google has classified as a known threat. By default, the WebView shows an interstitial, as shown in Figure 1, warning the user of the known threat and giving them the option to load the URL anyway or return to a previous page that's safe.

In Android 8.1 Developer Preview, you can define programmatically how your app responds to a known threat:

  • You can control whether your app reports known threats to Safe Browsing.
  • You can have your app automatically perform a particular action--such as going back to safety--each time it encounters a URL that Safe Browsing classifies as a known threat.

Note: For optimal protection against known threats, wait until you've initialized Safe Browsing before you invoke a WebView object's loadUrl()method.

Video thumbnail extractor

The MediaMetadataRetriever class has a new method, getScaledFrameAtTime(), that finds a frame near a given time position and returns a bitmap with the same aspect ratio as the source frame, but scaled to fit into a rectangle of given width and height. This is useful for generating thumbnail images from video.

We recommend using this method rather than getFrameAtTime() which can waste memory because it returns a bitmap with the same resolution as the source video. For example, a frame from a 4K video would be a 16MB bitmap, far larger than you would need for a thumbnail image.

Shared memory API

Android 8.1 (API level 27) introduces a new SharedMemory class. This class allows you to create, map, and manage anonymous shared memory that can be used by multiple processes or apps.

WallpaperColors API

Android 8.1 Developer Preview (API level 27) adds support for managing wallpaper colors. This feature lets you create a WallpaperColors object from a bitmap, a drawable, or by using the first three most visually representative colors. You can also retrieve details of the first three noticeable colors of a wallpaper.

To create a WallpaperColors object, do either of the following:

  • To create a WallpaperColors object by using three colors, create an instance of the WallpaperColors class by passing the primary, the secondary, and the tertiary color. The primary color must not be null.
  • To create a WallpaperColors object from a bitmap, call the fromBitmap() method by passing the bitmap source as parameter.
  • To create a WallpaperColors object from a drawable, call the fromDrawable() method by passing the drawable source as parameter.

To retrieve the primary, secondary, or tertiary color details from the wallpaper, call the following methods:

  • getPrimaryColor() returns the most noticeable color of the wallpaper.
  • getSecondaryColor() returns the second most preeminent color of the wallpaper.
  • getTertiaryColor() method returns the third most preeminent color of the wallpaper

To notify the system about any significant color changes, call the notifyColorsChanged() method. This method triggers an onComputeColors()lifecycle event where you have an opportunity to provide a new WallpaperColors object.

To add a listener for color changes, you can call the addOnColorsChangedListener() method. You can also call the getWallpaperColors() method to retrieve the primary colors of a wallpaper.

Fingerprint updates

The FingerprintManager class has introduced the following error codes:

  • FINGERPRINT_ERROR_LOCKOUT_PERMANENT - The user has tried too many times to unlock their device using the fingerprint reader.
  • FINGERPRINT_ERROR_VENDOR - A vendor-specific fingerprint reader error occurred.

Full Specifications · Google Chrome Zing MP3

Phiên bản Preview
Cập nhật 25/10/2017 (7 năm trước)
Nhà phát triển Google
Thể loại Utilities & Operating Systems
Hệ điều hành Android
Hệ điều hành cài đặt Android
Yêu cầu Only compatible with the Nexus 5X, Nexus 6P, Pixel C, Pixel, Pixel XL, Pixel 2, and Pixel 2 XL.
Lượt tải về 87,430

Bình luận