NFC type V can’t get data :/ because of tag was lost java android

hello i’m beginner on java and i need to do an application for read and writte NFC type V tags.
i don’t understand why i get this error, my tag stay close to my phone and my phone detect the tag but idk why he log me “android.nfc.TagLostException: Tag was lost.”

i tried a lot off thing but nothing cool happen… like right now i have keep only the pricipal so i have this :
`private void readTagData(Tag tag) {

    NfcV nfcvTag = NfcV.get(tag);
    System.out.println(nfcvTag);
    TextView tv1 = (TextView)findViewById(R.id.textView);
    tv1.setText(nfcvTag.toString());
    try {
        nfcvTag.connect();
        byte[] cmd = new byte[] {
                (byte)0x00
        };
        byte[] response = nfcvTag.transceive(cmd);
        nfcvTag.close();

    } catch (IOException e) {
        e.printStackTrace();
    }
}`

thas is my function only to read data and i get the tag just before call it (i d’ont know if it’s good or bad to do that) by doing this currentTag = (Tag) intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

thanks for the help guys

  • 1

    I believe a lot of Tags will go in to the Halt state and won’t respond to additional communication if you send bad commands to them. I don’t think that sending it a single byte 00h is a valid command thus you are causing the TagLostException with a bad command. But as you don’t specify the make and model of the Tag it is hard to tell.

    – 

  • 1

    It is always a good idea to have a look into the tags datasheet to find the correct commands for the desired functionality

    – 

Leave a Comment