自动填充框架
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 8.0(API 级别 26)及更高版本支持自动填充框架。
某些应用(例如密码管理工具)可以使用用户提供的数据来填充其他应用中的视图。填充其他应用的视图的应用称为“自动填充服务”。自动填充框架负责管理应用与自动填充服务之间的通信。
填写表单是一项非常耗时且容易出错的任务。自动填充框架可通过提供以下优势来改善用户体验:
- 节省填写字段的时间。自动填充服务可让用户无需重复输入信息。
- 最大限度地减少用户输入错误。输入内容很容易出错,尤其是在移动设备上。尽量减少需要输入信息的情况可以将出现错别字的几率降至最低。
组件
自动填充框架包含以下高级组件:
- 自动填充服务:密码管理工具等可保存和存储能够在多个应用的视图中使用的用户信息的应用。
- 自动填充客户端:提供需要填充或保存用户数据的视图的应用。
- Android 系统:定义工作流程并提供能够使服务和客户端协同工作的基础架构的操作系统。
如需详细了解自动填充工作流程,请参阅 AutofillService
和 AutofillManager
参考文档。
指南
如需详细了解如何使用自动填充框架,请参阅以下指南:
- 针对自动填充优化应用
- 检查您的应用是否已配置为使用自动填充框架。
- 构建自动填充服务
- 实现您自己的自动填充服务。
- 将自动填充功能与键盘集成
- 让键盘和其他 IME 能够使用自动填充功能,并让自动填充提供程序能够支持 IME 集成。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Autofill framework\n\nThe autofill framework is available in Android 8.0 (API level 26) and higher.\n\nSome apps, such as password managers, can fill out the views in other apps with\ndata provided by the user. Apps that fill out other apps' views are called\n*autofill services*. The autofill framework manages the communication between an\napp and an autofill service.\n\nFilling out forms is a time-consuming and error-prone task. The autofill\nframework improves the user experience by providing the following benefits:\n\n- **Saving time spent filling in fields.** Autofill saves users from re-typing information.\n- **Minimizing user input errors.** Typing is prone to errors, especially on mobile devices. Minimizing the need to type information minimizes typos.\n\n| **Note:** Autofill works well with [Credential Manager](/identity/sign-in/credential-manager) and [passkeys](https://developers.google.com/identity/passkeys) to provide increased security and a smoother workflow.\n\nComponents\n----------\n\nThe autofill framework contains the following high-level components:\n\n- **Autofill services:** apps such as password managers that save and store user information that can be used in views across multiple apps.\n- **Autofill clients:** apps that provide views that need to be filled out or that hold the user's data.\n- **Android system:** the OS that defines the workflow and provides the infrastructure that makes services and clients work together.\n\nFor a detailed explanation of the autofill workflow, see the\n[`AutofillService`](/reference/android/service/autofill/AutofillService) and\n[`AutofillManager`](/reference/android/view/autofill/AutofillManager) reference\ndocumentation.\n\nGuides\n------\n\nTo learn more about how to use the autofill framework, see the following guides:\n\n[Optimize your app for autofill](/guide/topics/text/autofill-optimize)\n: Check that your app is configured for use with the autofill framework.\n\n[Build autofill services](/guide/topics/text/autofill-services)\n: Implement your own autofill service.\n\n[Integrate autofill with keyboards](/guide/topics/text/ime-autofill)\n: Enable keyboards and other IMEs to use autofill, and enable your autofill\n provider to support IME integration."]]