Android 7.1 示例
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
以下代码示例适用于 Android 7.1(API 25)。如需在 Android Studio 中下载这些示例,请依次选择 File > New > Import Sample 菜单选项。
注意:这些可下载的项目旨在与 Gradle 和 Android Studio 配合使用。
应用快捷方式示例
此示例演示了如何使用 Android 7.1(API 级别 25)中引入的 app shortcuts API。借助此 API,应用可以定义一组 intent;当用户长按应用的启动器图标时,系统便会显示这些 intent。我们分别提供了关于在 XML 中静态注册链接以及在运行时动态注册链接的示例。
应用快捷方式示例
图片键盘应用示例
此示例演示了如何使用 Android 支持库实现
Commit Content API。
此 API 提供了一种通用方式,使 IME 可以将图片和其他富媒体内容直接发送到应用中的文本编辑器,让用户可以使用自定义表情符号、贴纸或其他应用提供的其他富媒体内容撰写内容。
图片键盘应用示例
图片键盘 IME 示例
此示例演示了如何使用
Commit Content API 和 Android 支持库编写自定义图片键盘。
此键盘将显示在兼容的应用(也使用 Commit Content API)中,让用户能够将表情符号、贴纸或其他富媒体内容插入文本编辑器。
图片键盘 IME 示例
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Android 7.1 Samples\n\nThe following code samples are provided for Android 7.1 (API 25). To\ndownload the samples in Android Studio, select the **File \\\u003e New \\\u003e Import Sample** menu\noption.\n\n\n**Note:** These downloadable projects are designed\nfor use with Gradle and Android Studio.\n\n### App shortcuts sample\n\n\nThis sample demonstrates how to use the [app shortcuts API](/guide/topics/ui/shortcuts)\nintroduced in Android 7.1 (API level 25). This API allows an application to define a set of\nintents which are displayed when a user long-presses on the app's launcher icon. Examples are\ngiven for registering links both statically in XML, as well as dynamically at runtime.\n\n\n[App shortcuts sample](https://github.com/android/user-interface-samples/tree/main/AppShortcuts)\n\n### Image keyboard app sample\n\n\nThis sample demonstrates how to implement the [Commit Content API](/reference/android/view/inputmethod/InputConnection#commitContent(android.view.inputmethod.InputContentInfo,%20int,%20android.os.Bundle)), using the [Android Support Library](/topic/libraries/support-library).\nThis API provides a universal way for IMEs to send images and other rich\ncontent directly to a text editor in an app, allowing users to compose\ncontent using custom emojis, stickers, or other rich content provided by\nother applications.\n\n\n[Image keyboard app sample](https://github.com/android/input-samples/tree/main/CommitContentSampleApp)\n\n### Image keyboard IME sample\n\n\nThis sample demonstrates how to write a [custom image keyboard](/preview/image-keyboard) using the [Commit Content API](/reference/android/view/inputmethod/InputConnection#commitContent(android.view.inputmethod.InputContentInfo,%20int,%20android.os.Bundle)) and the [Android Support Library](/topic/libraries/support-library).\nThis keyboard will be displayed inside compatible apps (also using the Commit\nContent API), allowing users to insert emojis, stickers, or other rich\ncontent into text editors.\n\n\n[Image keyboard IME sample](https://github.com/android/input-samples/tree/main/CommitContentSampleIME)"]]