如何读取NFC标签的所有记录或信息?

How to Read all Records or Message of NFC tag?

我按照 this 读取 NFC 标签...

所以我在这里得到 NFC 标签 ID,它是 Record[0] 通过使用 ByteArrayToHexString(intent.getByteArrayExtra(NfcAdapter.EXTRA_ID))

我想以类似的方式读取 NFC Record 1,Record 2,Record[3] 或 NFC 消息.. NfcAdapter.EXTRA_NDEF_MESSAGES

这里只有一个标签在读取 我要获取标签的多条记录

谁能推荐我这种类型的....

网上有很多教程,简单搜索一下就得到了这样的代码:

    @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
            }
        }
    }