Android O: New Features and APIs
June 8, 2017 admin
single-blog-img

Google has recently released the Android O Developer Preview 2 and first public beta version. Android O introduces a variety of new features and capabilities for users and developers. This blog highlights what’s new in Android O.

Enhanced User Experience

  1. Redesigned Notifications

The notifications have been redesigned to provide easier and consistent way to manage notification behaviour and settings. Followings are the changes:

  • Notification Channel: Allows to create user-customizable for each specific notification. The UI refers to notification channels as notification category, for more information see https://developer.android.com/preview/features/notification-channels.html
  • Notification badges: Support for displaying notification badges on app launcher icon has been provided. To learn more visit the link, https://developer.android.com/preview/features/notification-badges.html
  • Snoozing: User can now snooze the notification display it again. Apps can remove or update a snoozed notification.
  • Notification Timeout: Now it’s possible to set a timeout to notification. After setting a timeout, a notification would be cancelled automatically when the timeout duration elapses.
  • Notification dismissal: The system can now predict whether the notification is dismissed by user manually or removed by app. To check how notifications are dismissed, you should implement the new onNotificationRemoved() method of https://developer.android.com/reference/android/service/notification/NotificationListenerService.html
  • Background color: A customized look and feel can be applied to notification to match with the style of an App. This should be ideally used for ongoing tasks which are critical for user to see at a glance. For instance, you can set a green background for a phone call in progress notification. You can set the desired background color using following method https://developer.android.com/reference/android/app/Notification.Builder.html#setColor(int).
  • Messaging style: Those notifications which use the MessagingStyle class now display more content in collapsed form. A new method addHistoricMessage() can be used to provide context to a conversation by adding historic message to messaging related notifications.
  1. Autofill Framework

The same way like Chrome browser auto-fills the saved information such as address and credit card numbers when it detects a compatible fields. Well, a similar feature is coming in Android O, which saves the user the hassle of repeatedly the same information on a touchscreen keyboard.

The new https://developer.android.com/preview/features/autofill.html Autofill framework allows apps to create and manage their own list of auto-fill data, then simply populate it into text field when appropriate. Even the user will have total control over the saved information.

  1. 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, developer should make sure app does not pause playback in its onPause() handler. Instead, developer should pause video in onStop(), and resume playback in onStart(). For more information, see Multi-Window Lifecycle.

To specify that activity can use PIP mode, set android:supportsPictureInPicture to true in the manifest.

  1. New Emojis

One major change in the new beta release is a set of revamped emojis. Google has finally ditched the blob-shaped smilies in favor of more traditional rounded ones, and most emojis now have a gradient applied to them.

The EmojiCompat support library prevents app from showing missing emoji characters. App users do not need to wait for Android OS updates to get the latest emoji. The library provides classes to implement backward-compatible emoji support on devices running Android 4.4 (API level 19) and higher.

  1. Fonts in XML

Android O introduces a new feature, Fonts in XML, which can be used 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. Then we can access these fonts with the help of a new resource type, font.

  1. Fingerprint Scanner Gesture

The Pixel and Pixel XL shipped with an exclusive feature that allowed users to expand their notification tray by swiping down on the phone’s fingerprint scanner. This feature has since been added to Nexus devices, but Google’s taking the fingerprint-swipe gesture to a whole new level in Android O.

Third-party app developers can now use an Accessibility service to monitor the fingerprint scanner for swipes—both vertical and horizontal. This means that, by requesting an extra permission, your favorite apps will get fingerprint gesture functionality.

  1. WebView APIs

Android O provides several APIs to manage the WebView objects that display web content in app. These APIs, which improve app’s stability and security, include the following:

  • Version API
  • Google SafeBrowsing API
  • Termination Handler API
  • Renderer Importance API
  1. Custom Lock Screen Shortcuts

Another great addition to the System UI Tuner is a new lock screen shortcuts menu. It lets you add custom shortcuts that will show up in the bottom corners of your lock screen. You can pick any installed app to occupy one of these spaces, and there are several handy shortcuts to choose from, such as one that opens your selfie camera directly.

  1. Maximum Screen Aspect Ratio

Apps that target Android 7.1 or lower have a default maximum screen aspect ratio of 1.86. Apps targeting Android O or higher do not have a default maximum aspect ratio. If your app needs to set a maximum aspect ratio, use the maxAspectRatio attribute in the manifest.

  1. Unified layout margins and padding

Android O makes it easier to specify situations where opposite sides of a View element use the same margin or padding. Specifically, you can now use the following attributes in your layout XML files:

  • layout_marginVertical, which defines layout_marginTop and layout_marginBottom at the same time.
  • layout_marginHorizontal, which defines layout_marginLeft and layout_marginRight at the same time.
  • paddingVertical, which defines paddingTop and paddingBottom at the same time.
  • paddingHorizontal, which defines paddingLeft and paddingRight at the same time.