我正在做一个移动编程项目。移动程序旨在将 uri 信息(如 http://example.com(写入 uri 有效负载和 wifi 凭据,以便当您点击 nfc 标签时,您可以连接到 wifi 并在浏览器中打开 URI。
我已经测试过将两个信息写入一个 nfc 标签,但它似乎没有同时提供两个操作。
如果项目成功点击 nfc 标签,手机必须弹出 wifi 连接并在浏览器中打开 uri。 如果有人有线索,我会很高兴跟随!
NDEF 消息由 NDEF 记录组成。在这种情况下,消息应包含 4 条记录,即:
- 表示 http://example.com 的 URI 记录类型
- 建议的操作记录
- 标题记录 W
- ifiSimpleConfiguration Record 由Wi-FiAlliance Mime Type define is application/vnd.wfa.wsc (Android Code that write suchrecord(
由前 3 条记录组成的 NDEF 消息如下所示。请自行更新它以包含第 4 条记录。----------
Offset Content Length Explanation
0 0xD1 1 NDEF header. TNF = 0x01(Well Known Type). SR=1, MB=1, ME=1
1 0x02 1 Record name length (2 bytes)
2 0x30 1 Length of the Smart Poster data (48 bytes)
3 “Sp” 2 The record name
5 0x81 1 NDEF header. TNF = 0x01, SR=0, MB=1, ME=0
6 0x01 1 Record name length (1 byte)
7 0x00, 0x00, 0x00, 0x0C 4 The length of the URI payload (12 bytes) (long format)
11 “U” 1 Record type: “U”
12 0x03 1 Abbreviation: “http://”
13 “example.com” 11 The URI itself.
24 0x11 1 NDEF record header (SR=1, TNF=0x01)
25 0x03 1 The length of the record name
26 0x01 1 The length of the “act” payload.
27 “act” 3 Record type: “act”
30 0x00 1 Action = Launch browser
31 0x11 1 NDEF record header (SR=1, TNF=0x01)
32 0x01 1 Length of the record name
33 0x12 1 Length of the record payload (18 bytes)
34 “T” 1 Record type: “T” (=Text)
35 0x05 1 Status byte for the Text (UTF-8, five-byte code)
36 “en-US” 5 ISO Language code: US-English
41 “Hello, world” 12 The text: “Hello world”, encoded in UTF-8.
----------
为了回答您是否可能让Android阅读器处理这些多条记录的问题,我们应该看看NFC标签调度系统
该系统创建一个意图 - 动作 = NfcAdapter.ACTION_NDEF_DISCOVERED - MimeType = 第一条记录的 mimetype
- Intent's Extra NfcAdapter.EXTRA_NDEF_MESSAGES 包含完整的 Ndef 消息
因此,Android 仅填充第一条记录的 mimetype。
它留给获取此意图的应用程序或服务,以根据需要处理所有 NDEF 记录。