How to extract data using IsoDep technology - NFC (Android)

I am using NFC technology for one of my Android projects. I have successfully implemented tag detection and based on the tag I know which class I need to use to retrieve the data. But there is one problem with the map I need to use / touch to get data using IsoDep technology and not NDEF. I know how to fetch data from a card that is working on NDEF technology, but I am stuck here due to IsoDep technology. I am sharing my code snippet with this question for a better understanding.

if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) || NfcAdapter.ACTION_TECH_DISCOVERED.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {

Tag tag = getIntent().getParcelableExtra(NfcAdapter.EXTRA_TAG);
IsoDep isoDep = IsoDep.get(tag);
isoDep.connect();
//code to get the data from card
isoDep.close()
}

      

So, I am getting TAG_DISCOVERED via NFCAdapter and inside the condition when I get IsoDep, tech.NFcA, NdefFormattable as tag variable value. I create an instance of the IsoDep class and call the connect () method. Here I am getting an IOException every time I try to start a connection to read data, which I don't know why !!! Can anyone help me solve this problem? Any help would be appreciated.

thank

+3


source to share


2 answers


First of all, you should check if the call worked by .get

checking if there is isoDep == null

.

As for yours IOException

, it is difficult to determine the specific cause of the problem if you cannot provide the code. Methods for extracting data from tags vary from manufacturer to manufacturer. You noted that the tag also supports NfcA

, it might be worth investigating if this technology doesn't work.



However, some things to consider:

  • Have you tried using more than one tag? Can you confirm that the problem is not related to the tag?
  • Is your NFC setting correct? Because of this, another illogical IOException may be thrown.
  • Are you calling .close()

    from a different thread? This will throw an IOException.
0


source


You can use TagInfo from PlayStore to find out the exact information about the card and then work from there. TapLinxSDK will probably help you too.



0


source







All Articles