天天看點

Android O 8.0新特性(四) 官方Demo

  • 首頁
  • Android
  • Oreo

主要采用的google翻譯,不當之處,還望指正.

Code Samples 代碼示例

Use the code samples below to learn about Android 8.0 (API level 26) 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.

使用下面的代碼示例了解Android 8.0(API級别26)功能和API。要在Android Studio中下載下傳示例,請選擇檔案>建立>導入示例菜單選項。

注意:這些可下載下傳項目專為Gradle和Android Studio使用而設計。

Notification Channels 通知管道

NotificationChannels Sample - Android 8.0 (API level 26) 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

NotificationChannels示例 - Android 8.0(API級别26)增加了對通知頻道的支援,應用程式可将其通知組織到主題類别中。每個類别都可以有自己的警報風格,使用者可以選擇性地啟用或禁用類别以符合他們的興趣。本示例示範如何建立頻道并适當注釋通知。

在GitHub上擷取它:Java |Kotlin

Autofill Framework 自動填充架構

AutofillFramework Sample - This sample demonstrates the use of the Autofill Framework introduced in Android 8.0 (API level 26). 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

自動填充架構示例 - 此示例示範如何使用Android 8.0(API級别26)中引入的自動填充架構。它包括希望自動填充的用戶端活動的實作以及可以向這些活動提供自動填充資料的服務。

在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

PictureInPicture示例 - 此示例示範手持裝置的畫中畫模式的基本用法。該示例播放視訊。當應用程式轉變為畫中畫模式時,視訊會繼續播放。在畫中畫螢幕上,應用程式會顯示一個操作項目以暫停或恢複視訊。

Downloadable Fonts 可下載下傳的字型

DownloadableFonts - This sample demonstrates how to use the Downloadable Fonts feature introduced in Android 8.0 (API level 26). 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

DownloadableFonts - 此示例示範如何使用Android 8.0(API級别26)中引入的可下載下傳字型功能。可下載下傳字型允許應用程式從提供者處請求特定字型,而不是捆綁或自行下載下傳。這意味着不需要獨立捆綁字型作為資源。

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

EmojiCompat - 此示例示範了Emoji Compatibility Support Library的用法。您可以使用此庫來防止您的應用程式以豆腐的形式顯示缺少表情符号字元(□)。您可以使用捆綁或可下載下傳的表情符号字型。該示例顯示了兩種用法。

在GitHub上擷取它:Java |Kotlin

Background Execution Limits 背景執行限制

Bluetooth Advertisements Sample - The Bluetooth Advertisements sample was updated to comply with Android 8.0 (API level 26)'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

藍牙廣告示例 - Bluetooth廣告示例已更新為符合Android 8.0(API級别26)的背景執行限制。該示例先前建立了用于廣播藍牙LE廣告的背景服務;此過程現在作為前台服務啟動以確定執行。

在GitHub上擷取它:Java

Background Location Restrictions 背景定位限制

LocationUpdatesPendingIntent Sample - Shows how to request location updates using a PendingIntent. For apps targeting Android 7.x (API levels 24-25) but running on Android 8.0 (API level 26), developers can use either PendingIntent.getService() or PendingIntent.getBroadcast(). For apps targeting Android 8.0, PendingIntent.getService() does not work due to the limits placed on services started in the background. When targeting Android 8.0, developers should use PendingIntent.getBroadcast().

Get it on GitHub: Java

LocationUpdatesPendingIntent示例 - 顯示如何使用PendingIntent請求位置更新。對于面向Android 7.x(API級别24-25)但在Android 8.0(API級别26)上運作的應用,開發人員可以使用PendingIntent.getService()或PendingIntent.getBroadcast()。對于面向Android 8.0的應用,PendingIntent.getService()不起作用,因為背景啟動的服務受到限制。在定位Android 8.0時,開發者應該使用PendingIntent.getBroadcast()。

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 8.0 (API level 26), 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

LocationUpdatesForegroundService示例 - 顯示如何在應用程式活動不可見時使用前台服務擷取位置更新。對于在Android 8.0(API級别26)上運作的應用程式,背景更新每小時僅限于幾次。使用前台服務是一種接收更頻繁更新的方法。

AAudio A音頻

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++

AAudio Echo Sample - AAudio是一種新的NDK API,可讓Pro Audio應用程式通路受支援裝置上的低延遲音頻。此示例示範如何建立一個輸入和輸出流,配置為循環回調。(?)

在GitHub上擷取它:C ++

官網位址:https://developer.android.com/about/versions/oreo/android-8.0-samples.html#nc