Search code examples
androidandroid-intentnfcndef

Read data from NFC that is put after NDEF content?


Let's say we've a custom chip that contains data stored as a NDEF and also custom data stored after the standard NDEF data. How could we read that data with Android?


Solution

  • Yes, this is possible. You can use the transceive(byte[] data) method to send RFID commands to the tag.

    Which commands to send depends what type of tag you are using. You should read the command structure for your type of tag (ISO14443 or ISO15693). In oder to use such commands you may have to dig a bit deeper in the standards to learn how to create the correct command sequence.

    Example for ISO15693, read single block, command code 0x20 (untested):

    byte[] readSingleBlock(int block) throws IOException {
    
        byte[] command = new byte[3];
            command[0] = 0x12;          // flags
            command[1] = 0x20;          // read single block command
            command[2] = (byte) block;
    
        byte result[] = nfcv.transceive(command);
        return result;
    }