【发布时间】:2014-02-25 19:19:21
【问题描述】:
我正在编写一个应用程序,它应该能够读取和写入类型 1、2、3 和 4 的 nfc 标签。我有 tag1、tag2 和 tag4 标签,它们都支持 NfcA 技术,我想使用 NfcA使用 trancieve(byte[]) 函数向标签发送命令的类 (http://developer.android.com/reference/android/nfc/tech/NfcA.html)。我如何以编程方式区分标签,以便我知道要使用的通信协议(所有标签类型的命令都不同)。
例如,下面分别对 Tag1 和 Tag2 执行读取命令:
// Note: nfcATag is an instance of android.nfc.tech.NfcA
byte[] readTag1Bytes = nfcATag.transcieve(new byte[] {0x01, 0x00, 0x00, id[0], id[1], id[2], id[3]}); // Id[] is a byte array that contains tag id
byte[] readTag2Bytes = nfcATag.transcieve(new byte[] {0x30, 0x00})
任何帮助表示赞赏..
【问题讨论】: