0

I am currently developing an app which will read NFC tags currently i have written the code to get TAG id what should i do next? How can i read all data if the intent extra namedEXTRA_NDEF_MESSAGES is empty.

the code for reading RFID i have for now is

public void onNewIntent(Intent intent) {
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

        String zin =  tag.getTechList()[0];
        info.setText("TagID: " + bytesToHex(tag.getId())+" Saturs: "+zin);    

 }

I would like to know how to read all data in that NFC tag.

Thank you allready!

J1and1
  • 920
  • 3
  • 12
  • 25
  • I am confused, do you read RFID or NFC tags? – ThomasRS Nov 12 '12 at 09:20
  • @Thomas sorry about that, i want to read RFID. – J1and1 Nov 12 '12 at 09:36
  • So why are you using the NfcAdapter? (Like in NFC != RFID) – ThomasRS Nov 12 '12 at 12:37
  • @Thomas there are lots similar app's that reads RFID cards using integrated phones NFC adapter! one of them is called e-talons reader and it works almost correctly...... i want to build something like that using the same tech. – J1and1 Nov 12 '12 at 12:56
  • In that case, do you have some links for those apps? – ThomasRS Nov 12 '12 at 21:35
  • @Thomas [e-talons reader](https://play.google.com/store/apps/details?id=com.janhouse.nfc.apis.mifare&feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5qYW5ob3VzZS5uZmMuYXBpcy5taWZhcmUiXQ..) reads `Mifare Rfid cards` [NFClasic](https://play.google.com/store/apps/details?id=com.pocketluxus.nfclassic&feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5wb2NrZXRsdXh1cy5uZmNsYXNzaWMiXQ..) reads `NFC` and `RFID` and both of them are using `NfcAdapter Class` to read them! – J1and1 Nov 13 '12 at 06:09
  • Where is the documentation? Because neither of those apps list RFID on their page. – ThomasRS Nov 13 '12 at 11:03
  • @Thomas Ok! maybe i am wrong, bu you could at least tell me how to read all data from that `NFC` tag if `ndef_messages` are empty – J1and1 Nov 13 '12 at 13:05
  • Edit your question and tell us what you already tried – ThomasRS Nov 13 '12 at 13:46

1 Answers1

0

Depends on your TAG's type. An example for an ultralight mifare

Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
MifareUltralight uTag = MifareUltralight.get(tagFromIntent);
uTag.connect(); //You should enclose this into a try-catch because of probably IOException
byte[] data = uTag.readPages(INDEX_OF_PAGES_YOU_WANT); //This returns 4 consecutive pages from the offset you declared. Each page weights 4 bytes
uTag.close();
Rasman
  • 5,349
  • 1
  • 25
  • 38
noni
  • 2,927
  • 19
  • 18