近距离无线通信 (NFC) 概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
近距离无线通信 (NFC) 是一组近距离无线技术,通常只有在距离不超过 4 厘米时才能启动连接。借助 NFC,您可以在 NFC 标签与 Android 设备之间或者两台 Android 设备之间共享小型负载。
标签的复杂度可能各有不同。简单标签仅提供读取和写入语义,有时可使用一次性可编程区域将卡片设置为只读。较复杂的标签可提供数学运算,还可使用加密硬件来验证对扇区的访问权限。最为复杂的代码包含操作环境,允许与针对代码执行的代码进行复杂的互动。存储在标签中的数据也可以采用多种格式编写,但许多 Android 框架 API 都基于名为 NDEF(NFC 数据交换格式)的 NFC Forum 标准。
支持 NFC 的 Android 设备同时支持以下两种主要操作模式:
- 读取器/写入器模式:支持 NFC 设备读取和写入被动 NFC 标签和贴纸。
- 卡模拟模式:支持 NFC 设备本身充当 NFC 卡。然后,可以通过外部 NFC 读取器(例如 NFC 销售终端)访问模拟 NFC 卡。
- NFC 基础知识
- 本文档介绍了 Android 如何处理发现的 NFC 标签、如何将应用相关数据告知应用以及如何在应用中处理 NDEF 数据,此外还简要介绍了支持 Android 基本 NFC 功能集的框架 API。
- 高级 NFC
- 此文介绍了可使用 Android 支持的各种标签技术的 API。如果您不处理 NDEF 数据,或者需要处理 Android 不一定完全理解的 NDEF 数据,您必须使用自己的协议堆栈以原始字节形式手动读取或写入标签。在这些情况下,Android 支持检测某些标签技术,还支持您使用自己的协议堆栈与标签进行通信。
- 基于主机的卡模拟
- 本文档介绍了 Android 设备如何在不使用安全元件的情况下充当 NFC 卡,同时支持任何 Android 应用模拟卡并直接与 NFC 读取器通信。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[[["易于理解","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-26。"],[],[],null,["# Near field communication (NFC) overview\n\nNear Field Communication (NFC) is a set of short-range wireless technologies,\ntypically requiring a distance of 4 cm or less to initiate a connection. NFC\nlets you share small payloads of data between an NFC tag and an\nAndroid-powered device, or between two Android-powered devices.\n\nTags can range in complexity. Simple tags offer just read and write semantics,\nsometimes with one-time-programmable areas to make the card read-only. More\ncomplex tags offer math operations, and have cryptographic hardware to\nauthenticate access to a sector. The most sophisticated tags contain operating\nenvironments, allowing complex interactions with code executing on the tag. The\ndata stored in the tag can also be written in a variety of formats, but many of\nthe Android framework APIs are based around a [NFC\nForum](http://www.nfc-forum.org/) standard called NDEF (NFC Data Exchange\nFormat).\n\nAndroid-powered devices with NFC simultaneously support two main modes of\noperation:\n\n1. **Reader/writer mode**, allowing the NFC device to read and write passive NFC tags and stickers.\n2. **Card emulation mode**, allowing the NFC device itself to act as an NFC card. The emulated NFC card can then be accessed by an external NFC reader, such as an NFC point-of-sale terminal.\n\n**[NFC Basics](/develop/connectivity/nfc/nfc)**\n: This document describes how Android handles discovered NFC tags and how it\n notifies applications of data that is relevant to the application. It also\n goes over how to work with the NDEF data in your applications and gives an\n overview of the framework APIs that support the basic NFC feature set of\n Android.\n\n**[Advanced NFC](/develop/connectivity/nfc/advanced-nfc)**\n: This document goes over the APIs that enable use of the various tag\n technologies that Android supports. When you are not working with NDEF data,\n or when you are working with NDEF data that Android cannot fully understand,\n you have to manually read or write to the tag in raw bytes using your own\n protocol stack. In these cases, Android provides support to detect certain\n tag technologies and to open communication with the tag using your own\n protocol stack.\n\n**[Host-based Card Emulation](/develop/connectivity/nfc/hce)**\n: This document describes how Android devices can perform as NFC cards without\n using a secure element, allowing any Android application to emulate a card\n and talk directly to the NFC reader."]]