New Features in Android 8.0 (Oreo) — Part 1

This document talks about the new features introduced in the latest version of the Android operating system i.e 8.0 or Oreo. Oreo was named Android O during development. The first preview of Android O was released in March 2017 and on Aug 21, 2017, it was released for public. API level 26 is introduced for Android Oreo.
New Features
This section entails the list of the features in the newer version.
Picture- in- Picture Mode (PIP Mode)
PIP mode was originally available for Android TV only. Oreo introduced this feature for other Android devices. It is a special type of multi-window -support used for video playback. Below attached image explains PIP mode functionality.
Implementation
- If an activity is in PIP mode, it will be in the paused state, but it should continue showing content. For this reason, the developer should make sure that the app does not pause playback in onPause().
- This support for PIP can be implemented by adding the following line in the manifest file.
android:supportsPictureInPicture = “true” - The following attribute can be set true if multi-window support is required for the app.
android:resizeableActivity = “true”
Notifications
Android O provides a new design for notifications to manage them in an easier and more consistent way. These changes can be listed as below:
- Oreo allows you to create a user-customizable channel for each type of notification you want to display.
- Oreo introduces support for displaying dots, or badges, on app launcher icons. Notification dots reflect the presence of notifications that the user has not yet dismissed or acted on.
- Oreo allows users to snooze notifications, which causes them to disappear for a period of time before reappearing. 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.
- Oreo allows you to set a timeout when creating a notification using setTimeoutAfter(). You can use this method to specify a duration after which a notification should be canceled. If required, you can cancel a notification before the specified timeout duration elapses.
- You can call setSettingsText() to set the text that appears when you create a link to your app’s notification settings from a notification using the intent given below: Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES
- The system may provide the following extras with the intent to filter the settings your app must display to users: EXTRA_CHANNEL_ID, NOTIFICATION_TAG, and NOTIFICATION_ID
- Users can dismiss notifications themselves, and apps can remove them programmatically. You can determine when a notification is dismissed and why it’s dismissed by implementing the onNotificationRemoved() method from the NotificationListenerService class.
- Background colors: You can 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 setColor(). Doing so allows you to use setColorized() to enable the use of a background color for a notification.
Autofill Framework
Android O makes filling out forms much easier, such as login and credit card forms, with the introduction of the Autofill Framework. Existing and new apps will work with Autofill Framework after the user opts into autofill.
Downloadable Fonts
Android O enables you to request fonts from a provider application instead of bundling fonts into the APK or letting the APK download fonts. This feature reduces your APK size, increases the app installation success rate, and allows multiple apps to share the same font.
Font in XML
Android O allows you to use fonts as resources in XML i.e. there is no need to bundle fonts in 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.
Autosizing Textview and Adaptive icons
Android 8.0 (API level 26) lets you set the size of your text to expand or contract automatically based on the size of the TextView. This means it is much easier to optimize the text size on different screens or with dynamic content. Android 8.0 introduces adaptive launcher icons. Adaptive icons support visual effects and can display a variety of shapes across different device models.
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.).
Webview Related Improvements
Android O provides some new APIs for improving app’s stability and security. These APIs will help you to manage the Webview.
- Version API
- Google Safe Browsing API
- Termination Handle API
- Renderer Importance API
App Shortcuts
Android provides to create a shortcut for all apps targeting Android 7.1 or higher. On Android 8.0 or higher, pinned shortcuts can be created. Unlike static and dynamic shortcuts, pinned shortcuts appear in supported launchers as separate icons.
Implementation:
- Use isRequestPinShortcutSupported() to check device compatibility for supporting pinned- shortcuts.
- Create ShortcutInfo object that contains only the existing shortcut’s ID if a shortcut already exists. The system finds and pins all other information related to the shortcut automatically.
- Create a ShortcutInfo object that contains an ID, an intent, and a short label for the new shortcut if you are creating a new shortcut.
- Pin the shortcut to the device’s launcher by calling requestPinShortcut(). Pass a pendingIntent which will notify that shortcut has pinned successfully.
Maximum screen aspect ratio
Android O introduces the maxAspectRatio attribute, which you can use to set your app’s maximum aspect ratio. In addition, in Android 8.0 and higher, an app’s default maximum aspect ratio is the native aspect ratio of the device on which the app is running.
Multi-display Support
In Android O, the multi-display feature has been enhanced. If an activity supports multi-window mode and is running on a device with multiple displays, it allows a user to switch activity from one display to another.
3.12 Unified Layout Margins and Paddings
Android O allows you to use following attributes in layout XML file:
- layout_marginVertical, which defines layout_marginTop and layout_marginBotton at same time.
- layout_marginHorizontal, which defines layout_marginLeft and layout_marginRight at same time.
- paddingVertical, which defines paddingTop and paddingBottom.
- paddingHorizontal, which defines paddingLeft and paddingRight.
Pointer Capture and App Categories
Pointer capture is a new feature in Android O, which control by delivering all mouse events to a focused view of the app. This feature is useful for games, remote desktop and virtualization clients. The View in the app can request pointer capture and define a listener to process captured pointer events. The mouse pointer is hidden while in this mode. The view can release pointer capture when it doesn’t need the mouse information anymore. The system can also release pointer capture when the view loses focus.
Android O also provides flexibility to declare relevant app categories. These categories are used to cluster together apps of similar purpose or function when presenting them to users, such as in Data Usage, Battery Usage, or Storage Usage. You can define a category for your app by setting the following attribute in the manifest file:
android:appCategory