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

General Tech Technology & Software 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Technology & Software related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago


I'm using NFC technology for one of my projects in Android. I have successfully implemented the Tag detection and based on the Tag I know which class I need to use to extract the data. But there is one problem the card which I need to use/tap to get the data is using the IsoDep technology rather than NDEF one. I know how to extract the data from a card which is working on NDEF technology but I'm getting stuck here because of the IsoDep technology. I'm sharing my code snippet with this question for 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 here I'm getting TAG_DISCOVERED through NFCAdapter and inside the condition I'm getting IsoDep, tech.NFcA, NdefFormattable as tag variable value. I'm creating the instance of IsoDep class and calling connect() method. Here I'm getting IOException everytime I'm trying to start the connection to read the data I don't know why !!! Can anyone help me to solve this? Any help would be appreciable.

Thanks

profilepic.png
manpreet 2 years ago


First of all, you should check whether or not the .get call worked by checking whether isoDep == null.

As for your IOException, it is hard to identify the specific cause of the issue 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 too.

However, some things to consider:

  • Have you tried with more than 1 tag? Can you confirm the tag/issue">issue isn't related to the tag?
  • Do you have the NFC permission setup correctly? An otherwise illogical IOException could be because of this.
  • Are you calling .close() from another thread? This will cause the IOException.

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.