Skip to content

Most visited

Recently visited

navigation

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.

User Experience

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:

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, see Multi-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 set android:resizeableActivity if your activity supports other multi-window modes.)

API changes

Android O introduces a new object, android.app.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:

Emoji compatibility

The EmojiCompat support library prevents your app from showing missing emoji characters. Your 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.

For more information about using the EmojiCompat support library, refer to Emoji Compatibility.

Downloadable Fonts

Android O and Android Support Library 26 let you 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.

For more information about downloading fonts, refer to Downloadable Fonts.

Fonts in XML

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.

The Support Library 26 provides full support to this feature on devices running API versions 14 and higher.

For more information, about using fonts as resources and retrieving system fonts, see Fonts in XML.

Autosizing TextView

Android O lets you set the size of your text 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. For more information, about autosizing TextView in Android O, see Autosizing TextView.

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.).

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:

To learn more about how to use these APIs, see Managing WebViews.

Pinning shortcuts and widgets

Android O introduces in-app pinning of shortcuts and widgets. In your app, you can create pinned shortcuts and widgets for supported launchers, subject to user permission.

For more information, see the Pinning Shortcuts and Widgets preview feature guide.

Maximum screen aspect ratio

Apps that target Android 7.1 (API level 25) 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 file that defines your Activity.

Multi-display support

Beginning with Android O, the platform offers enhanced support for multiple displays. If an activity supports multi-window mode and is running on a device with multiple displays, users can move the activity from one display to another. When an app launches an activity, the app can specify which display the activity should run on.

Note: If an activity supports multi-window mode, Android O automatically enables multi-display support for that activity. You should test your app to make sure it works adequately in a multi-display environment.

Only one activity at a time can be in the resumed state, even if the app has multiple displays. The activity with focus is in the resumed state; all other visible activities are paused, but not stopped. For more information on the activity lifecycle when several activities are visible, see Multi-Window Lifecycle.

When a user moves an activity from one display to another, the system resizes the activity and issues runtime changes as necessary. Your activity can handle the configuration change itself, or it can allow the system to destroy the process containing your activity and recreate it with the new dimensions. For more information, see Handling Configuration Changes.

ActivityOptions provides two new methods to support multiple displays:

setLaunchDisplayId()
Specifies which display the activity should be shown on when it is launched.
getLaunchDisplayId()
Returns the activity's current launch display.

The adb shell is extended to support multiple displays. The shell start command can now be used to launch an activity, and to specify the activity's target display:

adb shell start <activity_name> --display <display_id>

Unified layout margins and padding

Android O makes it easier for you 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:

Note: If you customize your app's logic to support different languages and cultures, including text direction, keep in mind that these attributes don't affect the values of layout_marginStart, layout_marginEnd, paddingStart, or paddingEnd. You can set these values yourself, in addition to the new vertical and horizontal layout attributes, to create layout behavior that depends on the text direction.

Pointer capture

Some apps, such as games, remote desktop, and virtualization clients, greatly benefit from getting control over the mouse pointer. Pointer capture is a new feature in Android O that provides such control by delivering all mouse events to a focused view in your app.

Starting in Android O, a View in your 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, for example, when the user opens another app.

For information on how to use this feature in your app, see Pointer capture.

App categories

Android O allows each app to declare a category that it fits into, when relevant. 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 android:appCategory attribute in your <application> manifest tag.

Android TV launcher

Android O includes a new content-centric, Android TV home screen experience, which is available with the Android TV emulator and Nexus Player device image for Android O. The new home screen organizes video content in rows corresponding to channels, which are each populated with programs by an app on the system. Apps can publish multiple channels, and users can configure which channels that they wish to see on the home screen. The Android TV home screen also includes a Watch Next row, which is populated with programs from apps, based on the viewing habits of the user. Apps can also provide video previews, which are automatically played when a user focuses on a program. The APIs for populating channels and programs are part of the TvProvider APIs, which are distributed as a Android Support Library module with Android O.

AnimatorSet

Starting in Android O, the AnimatorSet API now supports seeking and playing in reverse. Seeking lets you set the position of the animation set to a specific point in time. Playing in reverse is useful if your app includes animations for actions that can be undone. Instead of defining two separate animation sets, you can play the same one in reverse.

System

New StrictMode detectors

Android O adds three new StrictMode detectors to help identify potential bugs in your app:

Cached data

Android O gives better guidance and behaviors around cached data. Each app is now given a disk space quota for cached data, as returned by getCacheQuotaBytes(UUID).

When the system needs to free up disk space, it will start by deleting cached files from apps that are the most over their allocated quota. Thus, if you keep your cached data under your allocated quota, your cached files will be some of the last on the system to be cleared when necessary. When the system is deciding what cached files to delete inside your app, it will consider the oldest files first (as determined by modified time).

There are also two new behaviors that you can enable on a per-directory basis to control how the system frees up your cached data:

Finally, when you need to allocate disk space for large files, consider using the new allocateBytes(FileDescriptor, long) API, which will automatically clear cached files belonging to other apps (as needed) to meet your request. When deciding if the device has enough disk space to hold your new data, call getAllocatableBytes(UUID) instead of using getUsableSpace(), since the former will consider any cached data that the system is willing to clear on your behalf.

Content provider paging

We've updated content providers to include support for loading a large dataset one page at a time. For example, a photo app with many thousands of images can query for a subset of the data to present in a page. Each page of results returned by a content provider is represented by a single Cursor object. Both a client and a provider must implement paging to make use of this feature.

For detailed information about the changes to content providers, see ContentProvider and ContentProviderClient.

Content refresh requests

The ContentProvider and ContentResolver classes now each include a refresh() method, making it easier for clients to know whether the information they request is up-to-date.

You can add custom content refreshing logic by extending ContentProvider. Make sure that you override the refresh() method to return true, indicating to your provider's clients that you've attempted to refresh the data yourself.

Your client app can explicitly request refreshed content by calling a different method, also called refresh(). When calling this method, pass in the URI of the data to refresh.

Note: Because you may be requesting data over a network, you should invoke refresh() from the client side only when there's a strong indication that the content is stale. The most common reason to perform this type of content refresh is in response to a swipe-to-refresh gesture, explicitly requesting the current UI to display up-to-date content.

JobScheduler improvements

Android O introduces a number of improvements to JobScheduler. These improvements make it easier for your app to comply with the new background execution limits, since you can generally use scheduled jobs to replace the now-restricted background services or implicit broadcast receivers.

Updates to JobScheduler include:

Custom data store

Android O lets you provide a custom data store to your preferences, which can be useful if your app stores the preferences in a cloud or local database, or if the preferences are device-specific. For more information about implementing the data store, refer to Custom Data Store.

findViewById() signature change

All instances of the findViewById() method now return <T extends View> T instead of View. This change has the following implications:

Media enhancements

VolumeShaper

There is a new VolumeShaper class. You can use it to perform short automated volume transitions like fade-ins, fade-outs, and cross fades.

Audio Focus Enhancements

Audio apps share the audio output on a device by requesting and abandoning audio focus. An app handles changes in focus by starting or stopping playback, or ducking its volume. There is a new AudioFocusRequest class. With this class, apps have new capabilites when handling changes in audio focus: automatic ducking and delayed focus gain.

Media metrics

A new getMetrics() method returns a PersistableBundle object containing configuration and performance information, expressed as a map of attributes and values. The getMetrics() method is defined for these media classes:

Metrics are collected separately for each instance and persist for the lifetime of the instance. If no metrics are available the method returns null. The actual metrics returned depend on the class.

MediaPlayer

Android O adds several new methods to the MediaPlayer class. These methods can improve your app's handling of media playback in several ways:

MediaRecorder

Metadata can be useful for offline processing. For example, gyro signals from the sensor could be used to perform video stabilization.

When adding a metadata track, the track's mime format must start with the prefix "application/". Writing metadata is the same as writing video/audio data except that the data does not come from a MediaCodec. Instead, the app passes a ByteBuffer with an associated timestamp to the writeSampleData() method. The timestamp must be in the same time base as the video and audio tracks.

The generated MP4 file uses the TextMetaDataSampleEntry defined in section 12.3.3.2 of the ISOBMFF to signal the metadata's mime format. When using MediaExtractor to extract the file with metadata track, the mime format of the metadata will be extracted into MediaFormat.

Audio playback control

Android O allows you to query and request how a device is producing sound. The following aspects of control over audio playback make it easier for your service to produce sound only under favorable device conditions.

New audio usage type for Google Assistant

The AudioAttributes class contains a new sound type, USAGE_ASSISTANT, which corresponds to the answers that the Google Assistant speaks on a device.

Changes to device audio playback

If you want your service to begin producing sound only when a specific device audio configuration is active, you can use the AudioManager class to register an instance of AudioManager.AudioPlaybackCallback, whose onPlaybackConfigChanged() method helps you identify the currently-active set of audio attributes.

Explicit requests for audio focus

Your service can submit a more fine-grained request for receiving device-wide audio focus by using the requestAudioFocus() method. Pass in an AudioFocusRequest object, which you create using AudioFocusRequest.Builder. In this builder class, you can specify the following options:

Note: When building your instance of AudioFocusRequest, if you indicate that your service can wait to produce sound by calling setAcceptsDelayedFocusGain(), you must also call setOnAudioFocusChangeListener() so that your service knows when it can begin producing sound.

Improved media file access

The Storage Access Framework (SAF) allows apps to expose a custom DocumentsProvider, which can provide access to files in a data source to other apps. In fact, a documents provider can even provide access to files that reside on network storage or that use a protocol like Media Transfer Protocol (MTP).

However, accessing large media files from a remote data source introduces some challenges:

Android O addresses each of these challenges by improving the Storage Access Framework.

Custom document providers

Starting in Android O, the Storage Access Framework allows custom documents providers to create seekable file descriptors for files residing in a remote data source. The SAF can open a file to get a native seekable file descriptor. The SAF then delivers discrete bytes requests to the documents provider. This feature allows a documents provider to return the exact range of bytes that a media player app has requested instead of caching the entire file in advance.

To use this feature, you need to call the new StorageManager.openProxyFileDescriptor() method. The openProxyFileDescriptor() method accepts a ProxyFileDescriptorCallback object as a callback. The SAF invokes the callback any time a client application performs file operations on the file descriptor returned from the documents provider.

Direct document access

As of Android O, you can use the getDocumentUri() method to get a URI that references the same document as the given mediaUri. However, because the returned URI is backed by a DocumentsProvider, media collection managers can access the document directly, without having to traverse trees of scoped directories. As a result, the media managers can perform file operations on the document significantly more quickly.

Caution: The getDocumentUri() method only locates media files; it doesn't grant apps permission to access those files. To learn more about how to obtain access permission to media files, see the reference documentation.

Paths to documents

When using the Storage Access Framework in Android O, you can use the findDocumentPath() method, available in both the DocumentsContract and DocumentsProvider classes, to determine the path from the root of a file system given a document's ID. The method returns this path in a DocumentsContract.Path object. In cases where a file system has multiple defined paths to the same document, the method returns the path that is used most often to reach the document with the given ID.

This functionality is particularly useful in the following scenarios:

Note: If your app has permission to access only some of the documents in the path, the return value of findDocumentPath() includes only the folders and documents that your app can access.

Connectivity

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.

Bluetooth

Android O enriches the platform's Bluetooth support by adding the following features:

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 the Bluetooth section of the Android O Behavior Changes page.

Sharing

Smart sharing

Android O learns about users' personalized sharing preferences and better understands for each type of content which are the right apps to share with. For example, if a user takes a photo of a receipt, Android O can suggest an expense-tracking app; if the user takes a selfie, a social media app can better handle the image. Android O automatically learns all these patterns according to users' personalized preferences.

Smart sharing works for types of content other than image, such as audio, video, text, URL, etc.

To enable Smart sharing, add an ArrayList of up to three string annotations to the intent that shares the content. The annotations should describe the major components or topics in the content. The following code example shows how to add annotations to the intent:

ArrayList<String> annotations = new ArrayList<>();

annotations.add("topic1");
annotations.add("topic2");
annotations.add("topic3");

intent.putStringArrayListExtra(
    Intent.EXTRA_CONTENT_ANNOTATIONS,
    annotations
);

For detailed information about Smart sharing annotations, see EXTRA_CONTENT_ANNOTATIONS.

Smart text selection

On compatible devices, Android O enables apps to help users interact with text in more meaningful ways. When users long-press on a word in an entity—a recognized format like an address or restaurant name, for example—the system selects the whole entity. The user sees a floating toolbar that might include an app that can handle the selected text entity. For example, if the system recognizes an address, it can direct the user towards the Maps app.

Entities recognized by the system include addresses, URLs, telephone numbers, and email addresses. For more information, see TextClassifier.

Accessibility

Android O supports the following accessibility features for developers who create their own accessibility services. To learn more about how to make your app more accessible, see Accessibility.

Accessibility button

Your accessibility service can now request that an accessibility button appear within the system's navigation area, which gives users a quick way to activate your service's functionality from anywhere on their device. To do so, add the FLAG_REQUEST_ACCESSIBILITY_BUTTON flag in an AccessibilityServiceInfo object's android:accessibilityFlags attribute. You can then register callbacks using registerAccessibilityButtonCallback().

Note: This feature is available only on devices that provide a software-rendered navigation area. Always use isAccessibilityButtonAvailable(), and respond to changes based on the availability of the accessibility button by implementing onAvailabilityChanged(). That way, users can always access your service's functionality, even if the accessibility button isn't supported or becomes unavailable.

Independent volume adjusting

Android O introduces the STREAM_ACCESSIBILITY volume category, which allows you to control the volume of your accessibility service's audio output independently of other sounds on the device.

To use this new stream type to control accessibility volume, set the FLAG_ENABLE_ACCESSIBILITY_VOLUME option within your accessibility service. You can then change the device's accessibility audio volume using adjustStreamVolume().

Fingerprint gestures

Your accessibility service can also respond to an alternative input mechanism, directional swipes (up, down, left, and right) along a device's fingerprint sensor. To receive callbacks about these interactions, complete the following sequence of steps:

  1. Declare the USE_FINGERPRINT permission and the AccessibilityServiceInfo.CAPABILITY_CAN_CAPTURE_FINGERPRINT_GESTURES capability.
  2. Set the AccessibilityServiceInfo.FLAG_CAPTURE_FINGERPRINT_GESTURES flag within the android:accessibilityFlags attribute.
  3. Register for callbacks using registerFingerprintGestureCallback().

Keep in mind that not all devices include fingerprint sensors. You can use the isHardwareDetected() method to identify whether a device supports the sensor. Even on devices that include a fingerprint sensor, your service can use the sensor only when it's not in use for authentication purposes. To identify when the sensor is available, call the isGestureDetectionAvailable() method and implement the onGestureDetectionAvailabilityChanged() callback.

Word-level highlighting

To determine the locations of visible characters in a TextView object, you can pass in EXTRA_DATA_TEXT_CHARACTER_LOCATION_KEY as the first argument into refreshWithExtraData(). A Bundle object, which you provide as the second argument to refreshWithExtraData(), is then updated to include a parcelable array of Rect objects. Each Rect object represents the bounding box of a particular character.

If your service uses a TextToSpeech object to dictate the content that appears on-screen, you can obtain more precise timing information about when text-to-speech engines begin speaking individual synthesized words, as long as the text-to-speech engine provides this information. When an engine expects to begin playing audio for a specific range of text, the text-to-speech API notifies your service that speech for the range of text is beginning using the UtteranceProgressListener.onUtteranceRangeStart() callback.

If you create your own implementation of TextToSpeechService, you can support this new functionality by using the rangeStart() method.

Standardized one-sided range values

Some instances of AccessibilityNodeInfo use an instance of AccessibilityNodeInfo.RangeInfo to indicate that a UI element can take on a range of values. When creating a range using RangeInfo.obtain(), or when retrieving the extreme values of the range using getMin() and getMax(), keep in mind that Android O has standardized definitions of one-sided ranges:

Hint text

Android O includes several methods for interacting with a text-editable object's hint text:

Continued gesture dispatch

Your service can now specify sequences of strokes that belong to the same programmatic gesture by using the final argument, isContinued, in the GestureDescription.StrokeDescription constructor.

Security & Privacy

Permissions

Android O introduces several new permissions related to telephony:

These permission are both classified as dangerous and are both part of the PHONE permission group.

New account access and discovery APIs

Android O introduces several improvements to how apps get access to user accounts. For the accounts that they manage, authenticators can use their own policy to decide whether to hide accounts from, or reveal accounts to, an app. The Android system tracks applications which can access a particular account.

In previous versions of Android, apps that wanted to track the list of user accounts had to get updates about all accounts, including accounts with unrelated types. Android O adds the addOnAccountsUpdatedListener(android.accounts.OnAccountsUpdateListener, android.os.Handler, boolean, java.lang.String[]) method, which lets apps specify a list of account types for which account changes should be received.

API changes

AccountManager provides six new methods to help authenticators manage which apps can see an account:

Android O introduces two special Package Name values to specify visibility levels for applications which were not set using the setAccountVisibility(android.accounts.Account, java.lang.String, int) method. The PACKAGE_NAME_KEY_LEGACY_VISIBLE visibility value is applied to apps that have the GET_ACCOUNTS permission, and target versions of Android lower than Android O, or whose signatures match the authenticator targeting any Android version. PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE provides a default visibility value for apps which were not set previously and for which PACKAGE_NAME_KEY_LEGACY_VISIBLE is not applicable.

For more information about the new account access and discovery APIs, see the reference for AccountManager and OnAccountsUpdateListener.

Google Safe Browsing API

The WebView class now includes a Safe Browsing API to enhance the security of web browsing. For more information, see Google Safe Browsing API.

Testing

Instrumentation testing

Android O provides the following pieces of additional support for your app's instrumentation tests.

Run against non-default app processes

You can now specify that a particular instrumentation test should run against a process outside your app's default process. This configuration is useful if your app contains multiple activities that run in different processes.

To define non-default process instrumentation, navigate to your manifest file, then to the desired <instrumentation> element. Add the android:targetProcess attribute, and set its value to one of the following:

While your instrumentation test is executing, you can check which process it's testing by calling getProcessName().

Report results during a test

You can now report results while your instrumentation test is executing, rather than afterward, by calling addResults().

Mock intents for tests

To make it easier to create isolated, independent UI tests for your app's activities, Android O introduces the ActivityMonitor.onMatchIntent() method. You override this method in a custom subclass of the Instrumentation.ActivityMonitor class to handle a particular intent that your test class invokes.

When your test class invokes the intent, the method returns a stub Instrumentation.ActivityResult object instead of executing the intent itself. By using this mock intent logic in your tests, you can focus on how your activity prepares and handles the intent that you pass to a different activity or to an entirely different app.

Runtime & Tools

Platform optimizations

Android O brings runtime and other optimizations to the platform that result in a number of performance improvements. These optimizations include concurrent-compaction garbage collection, more efficient use of memory, and code locality.

These optimizations result in faster boot times, as well as better performance in both the OS and apps.

Updated Java Support

Android O adds support for several additional OpenJDK Java APIs:

To learn more about the classes and methods within these newly-added packages, see the API reference documentation.

If you want to use Java 8 language features in Android Studio, you should download the latest preview version.

Updated ICU4J Android Framework APIs

Android O extends the ICU4J Android Framework APIs—which is a subset of the ICU4J APIs—for app developers to use under the android.icu package. These APIs use localization data present on the device, so you can reduce your APK footprint by not compiling the ICU4J libraries in your APK.

Table 1. ICU, CLDR, and Unicode versions used in Android.

Android API level ICU version CLDR version Unicode version
Android 7.0 (API level 24), Android 7.1 (API level 25) 56 28 8.0
Android O 58.2 30.0.3 9.0
To learn more about the updates to the supported ICU4J APIs, read the release notes.

Android enterprise

New enterprise features and APIs have been introduced for devices running Android O. Highlights include the following:

To learn more about these and other new Android enterprise APIs and features, see Android in the Enterprise.

This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.