Google announced Android O Developer Preview for Developers

Android O Features and APIs

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.

Notifications

In Android O, we've redesigned notifications to provide an easier and more consistent way to manage notification behavior and settings. These changes include:
  • Notification channels: Android O introduces notification channels that allow you to create a user-customizable channel for each type of notification you want to display. The user interface refers to notification channels as notification categories. To learn how to implement notification channels, see the Notification Channels guide.
  • Snoozing: Users can snooze notifications to reappear at a later time. Notifications reappear with the same level of importance they first appeared with. Apps can remove or update a snoozed notification, but updating a snoozed notification does not cause it to reappear.
  • Notification timeouts: You can now set a timeout when creating a notification usingNotification.Builder.setTimeout(). You can use this method to specify a duration after which a notification should be cancelled. If required, you can cancel a notification before the specified timeout duration elapses.
  • Notification dismissal: The system now distinguishes whether a notification is dismissed by a user, or removed by an app. To check how notifications are dismissed, you should implement the newonNotificationRemoved() method of the NotificationListenerService class.
  • Background colors: You can now set and enable a background color for a notification. You should only use this feature in notifications for ongoing tasks which are critical for a user to see at a glance. For example, you could set a background color for notifications related to driving directions, or a phone call in progress. You can also set the desired background color using Notification.Builder.setColor(). Doing so allows you to use Notification.Builder.setColorized() to enable the use of a background color for a notification.
  • Messaging style: Notifications that use the MessagingStyle class now display more content in their collapsed form. You should use the MessagingStyle class for notifications that are messaging-related. You can also use the new addHistoricMessage() method to provide context to a conversation by adding historic messages to messaging related notifications.
Autofill Framework

Account creation, login, and credit card transactions take time and are prone to errors. Users can easily get frustrated with apps that require these types of repetitive tasks.
Android O makes filling out forms, such as login and credit card forms, easier with the introduction of the Autofill Framework. Existing and new apps work with Autofill Framework after the user opts in to autofill.
You can take some steps to optimize how your app works with the framework. For more information, see Autofill Framework Overview.

Picture-in-Picture mode


Android O allows activities to launch in picture-in-picture (PIP) mode. PIP is a special type of multi-window mode mostly used for video playback. PIP mode is already available for Android TV; Android O makes the feature available on other Android devices.
When an activity is in PIP mode, it is in the paused state, but should continue showing content. For this reason, you should make sure your app does not pause playback in its onPause() handler. Instead, you should pause video in onStop(), and resume playback in onStart(). For more information, seeMulti-Window Lifecycle.
To specify that your activity can use PIP mode, set android:supportsPictureInPicture to true in the manifest. (Beginning with Android O, you do not need to set android:resizeableActivity to true if you are supporting PIP mode, either on Android TV or on other Android devices; you only need to setandroid:resizeableActivity if your activity supports other multi-window modes.)

API changes



Android O introduces a new object, PictureInPictureArgs, which you pass to PIP methods to specify how an activity should behave when it is in PIP mode. This object specifies properties such as the activity's preferred aspect ratio.
The existing PIP methods described in Adding Picture-in-picture can now be used on all Android devices, not just on Android TV. In addition, Android O provides the following methods to support PIP mode:
  • Activity.enterPictureInPictureMode(PictureInPictureArgs args): Places the activity in picture-in-picture mode. The activity's aspect ratio and other configuration settings are specified by  args. If any fields in  args are empty, the system uses the values set the last time you called Activity.setPictureInPictureArgs().
    The specified activity is placed in a corner of the screen; the rest of the screen is filled with the previous activity that was on screen. The activity entering PIP mode goes into the paused state, but remains started. If the user taps the PIP activity, the system shows a menu for the user to interact with; no touch events reach the activity while it is in the PIP state.
  • Activity.setPictureInPictureArgs() Updates an activity's PIP configuration settings. If the activity is currently in PIP mode, the settings are updated; this is useful if activity's aspect ratio changes. If the activity is not in PIP mode, these configuration settings are used regardless of theenterPictureInPictureMode() method that you call.

Working with fonts


Android O introduces a new feature, Fonts in XML, which lets you use fonts as resources. This means, there is no need to bundle fonts as assets. Fonts are compiled in R file and are automatically available in the system as a resource. You can then access these fonts with the help of a new resource type, font. Android O also provides a mechanism to retrieve information related to system fonts and provide file descriptors. For more information, about using fonts as resources and retrieving system fonts, see Working with fonts.

Adaptive icons


Android O introduces adaptive launcher icons. Adaptive icons support visual effects, and can display a variety of shapes across different device models. To learn how to create adaptive icons, see the Adaptive Icons preview feature guide.

Color management


Android developers of imaging apps can now take advantage of new devices that have a wide-gamut color capable display. To display wide gamut images, apps will need to enable a flag in their manifest (per activity) and load bitmaps with an embedded wide color profile (AdobeRGB, Pro Photo RGB, DCI-P3, etc.).

Wi-Fi Aware


Android O adds support for Wi-Fi Aware, which is based on the Neighbor Awareness Networking (NAN) specification. On devices with the appropriate Wi-Fi Aware hardware, apps and nearby devices can discover and communicate over Wi-Fi without an Internet access point. We're working with our hardware partners to bring Wi-Fi Aware technology to devices as soon as possible. For information on how to integrate Wi-Fi Aware into your app, see Wi-Fi Aware.

Companion device pairing


Android O provides APIs that allow you to customize the pairing request dialog when trying to pair with companion devices over Bluetooth, BLE, and Wi-Fi. For more information, see Companion Device Pairing.
For more information about using Bluetooth on Android, see the Bluetooth guide. For changes to Bluetooth that are specific to Android O, see theBluetooth section of the Android O Behavior Changes page.

WebView APIs


Android O provides several APIs to help you manage the WebView objects that display web content in your app. These APIs, which improve your app's stability and security, include the following:
  • Version API
  • Google SafeBrowsing API
  • Termination Handle API
  • Renderer Importance API
To learn more about how to use these APIs, see Managing WebViews.

Comments