Skip to content

Most visited

Recently visited

navigation

Code Samples

Use the code samples below to learn about Android O capabilities and APIs. To download the samples in Android Studio, select the File > New > Import Samples menu option.

Note: These downloadable projects are designed for use with Gradle and Android Studio.

Notification Channels

NotificationChannels Sample - Android O adds support for notification channels, apps to organize their notifications into topical categories. Each category can have its own alert style, and users are able to selectively enable or disable categories to match their interests. This sample demonstrates how to create channels and appropriately annotate notifications.

Get it on GitHub: Java | Kotlin

Autofill Framework

AutofillFramework Sample - This sample demonstrates the use of the Autofill Framework introduced in Android O. It includes implementations of client Activities that want to be autofilled, and a Service that can provide autofill data to those Activities.

Get it on GitHub: Java | Kotlin

Picture-in-Picture Mode

PictureInPicture Sample - This sample demonstrates basic usage of Picture-in-Picture mode for handheld devices. The sample plays a video. The video keeps on playing when the app is turned into Picture-in-Picture mode. On Picture-in-Picture screen, the app shows an action item to pause or resume the video.

Get it on GitHub: Java | Kotlin

Downloadable Fonts

DownloadableFonts - This sample demonstrates how to use the Downloadable Fonts feature introduced in Android O. Downloadable Fonts allows apps to request a certain font from a provider, instead of bundling it or downloading it themselves. This means there is no need to independently bundle the font as an asset.

Get it on GitHub: Java | Kotlin

EmojiCompat - This sample demonstrates usage of the Emoji Compatibility Support Library. You can use this library to prevent your app from showing missing emoji characters in the form of tofu (□). You can use either bundled or downloadable emoji fonts. This sample shows both usages.

Get it on GitHub: Java | Kotlin

Background Execution Limits

Bluetooth Advertisements Sample - The Bluetooth Advertisements sample was updated to comply with Android O's background execution limits. The sample previously created a background service which was used to broadcast Bluetooth LE Advertisements; this process is now started as a foreground service to ensure execution.

Get it on GitHub: Java

Background Location Restrictions

LocationUpdatesPendingIntent Sample - Shows how to request location updates using a PendingIntent. For apps targeting Android 7.0 but running on Android O, developers can use either PendingIntent.getService() or PendingIntent.getBroadcast(). For apps targeting Android O, PendingIntent.getService() does not work due to the limits placed on services started in the background. When targeting Android O, developers should use PendingIntent.getBroadcast().

Get it on GitHub: Java

LocationUpdatesForegroundService Sample - Shows how to use a foreground service to get location updates when the app activities are not visible. For apps running on Android O (even apps that target Android 7.0 (API level 24) or lower), background updates are limited to only a few times per hour. Using a foreground service is a way to receive more frequent updates.

Get it on GitHub: Java

AAudio

AAudio Echo Sample - AAudio is a new NDK API that gives Pro Audio apps access to low-latency audio on supported devices. This sample demonstrates how to create an input and output stream, configured for loopback.

Get it on GitHub: C++

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

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

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.