I have an Android app that reads NFC tags. Everything works fine on the LG Nexus 4 but on Samsung Galaxy S5 I only get I/O exceptions (tested on multiple phones).
So, tags are of type NfcV and I get the I/O exception when calling connect()
on the NfcV (further down it is error code -5 ERROR_CONNECT).
NFC TagInfo by NXP can read the the memory content of the tag on the SG5S - are there other ways of reading NfcV tags than with connect()
and transceive()
?
What differences between NFC chips will cause my app's connection to fail on one phone but not the other (while other apps read it fine)? Are there timeouts I need to adjust maybe?
Code snippet:
NfcV nfcvTag = NfcV.get(intent.getParcelableExtra(NfcAdapter.EXTRA_TAG));
if(nfcvTag!=null){
try {
nfcvTag.connect();
//{flags:0x00, read multiple blocks command: 0x23, start at block 0: 0x00, read 9 blocks (0 to 8): 0x08}
response = nfcvTag.transceive(new byte[] {(byte)0x00,(byte)0x23,(byte)0x00,byte)0x08});
} catch (IOException e) {
Log.d("NFCService", nfcvTag.toString());
} finally {
try {
nfcvTag.close();
} catch (IOException e) {
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…