I'm trying to read NfcA tag in my application. my code is as below. i referred here and some connected SO questions for transceive commands, But I'm keep getting android.nfc.TagLostException: Tag was lost.
exception.
Im using Samsung Galaxy S4 for debugging.
Is there any possibility card is not a valid card or any security shield can cause the exception?
NfcA mifare = NfcA.get(tag); // tag "TAG: Tech [android.nfc.tech.NfcA]"
if (mifare != null){
try {
mifare.connect();
mifare.setTimeout(5000);
if (mifare.isConnected()) {
int firstBlockNum = 0;
int lastBlockNum = 42;
byte[] command = new byte[]{
(byte)0x3A, // FAST_READ
(byte)(firstBlockNum & 0x0ff),
(byte)(lastBlockNum & 0x0ff)
};
byte[] result = mifare.transceive(command);
} catch (IOException e) {
Log.e("Error communicating with card: ", e.toString());
}
}
}