我跟着这读NFC标签..。
所以这里我得到了NFC标记ID,它是通过使用ByteArrayToHexString(intent.getByteArrayExtra(NfcAdapter.EXTRA_ID))
记录的。
我想以类似的方式阅读NFC记录1,记录2,Record3那样或者NFC消息..NfcAdapter.EXTRA_NDEF_MESSAGES
这里只有一个标记正在读取,我想获取多个标签的记录。
有人能给我推荐这种..。
发布于 2015-11-30 13:41:42
网上有很多教程,一个简单的搜索就给了你这样的代码:
@Override
protected void onNewIntent(Intent intent) {
String action = intent.getAction();
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
Ndef ndef = Ndef.get(tag);
if (ndef == null) {
// NDEF is not supported by this Tag.
return;
}
NdefMessage ndefMessage = ndef.getCachedNdefMessage();
NdefRecord[] records = ndefMessage.getRecords();
for (NdefRecord ndefRecord : records) {
//read each record
}
}
}
https://stackoverflow.com/questions/33970970
复制相似问题