安卓NFC与相机功能开发全解析
1. NFC技术简介
NFC(近场通信)是一种特殊的RFID射频技术,工作频率为13.56MHz。在安卓平台上,使用NFC技术开发应用时,建议使用NDEF(NFC数据交换格式)数据,以简化开发过程。
2. 读取NFC标签信息
以下代码展示了如何输出Ndef对象的一些有用属性,如类型、最大容量、是否可写以及是否可设为只读:
Ndef ndef = Ndef.get(detectedTag);
// Get the NDEF tag type (such as NFC_FORUM_TYPE_1 through
// NFC_FORUM_TYPE_4 and MIFARE_CLASSIC)
Log.d(TAG, ndef.getType().toString());
// Get the maximum NDEF message size in bytes
Log.d(TAG, Integer.toString(ndef.getMaxSize()));
// Determine if the tag is writable.
Log.d(TAG, ndef.isWritable() ? "true" : "false");
// Indicates whether a tag can be made read-only
Log.d(TAG, ndef.canMakeReadOnly() ? "true" : "false");
也可以使用 getNdefMessage() 方法读取NDEF消息:
超级会员免费看
订阅专栏 解锁全文
1198

被折叠的 条评论
为什么被折叠?



