近距離無線通訊 (NFC) 總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
近距離無線通訊 (NFC) 是一組短距離無線通訊技術,通常需要在 4 公分以內的距離才能建立連線。NFC 可讓您在 NFC 標記和 Android 裝置之間,或在兩部 Android 裝置之間分享小型資料酬載。
代碼的複雜度不一,簡單的標記只提供讀取和寫入語意,有時會提供一次性可編程區域,讓卡片成為唯讀。更複雜的標記可提供數學運算,並提供加密編譯硬體,以驗證對某個區塊的存取權。最精密的代碼包含作業環境,可讓代碼在代碼上執行複雜的互動。標籤中儲存的資料也可以以多種格式寫入,但許多 Android 架構 API 都是以 NFC 論壇標準為基礎,稱為 NDEF (NFC 資料交換格式)。
搭載 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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間: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."]]