1. 程式人生 > >Android O 8.0新特性(四) 官方Demo

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

主要採用的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 | 

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 | 自動填充框架示例 - 此示例演示如何使用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 | 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 | 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 | 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: JavaLocationUpdatesPendingIntent示例 - 顯示如何使用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: JavaLocationUpdatesForegroundService示例 - 顯示如何在應用程式活動不可見時使用前臺服務獲取位置更新。對於在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 ++