I'm developing an Android application which needs to read an NFC card (the card technology is NFC-F). There, I always get following exception:
android.nfc.TagLostException: Tag was lost.
Here is my code:
private void handleIntent(Intent intent) {
String action = intent.getAction();
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
} else if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
} else if(NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) {
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
if (tag != null) {
NfcF nfcf = NfcF.get(tag);
try {
nfcf.connect();
byte[] AUTO_POLLING_START = {(byte) 0xE0, 0x00, 0x00, 0x40, 0x01};
byte[] response = nfcf.transceive(AUTO_POLLING_START);
nfcf.close();
} catch (Exception e) {
e.printStackTrace();
mTextView.setText(e.toString());
}
}
}
}
Can anyone help me regarding this issue?