Currently we are developing NFC applications for Android. Our experience
Developed POS NFC control system using NXP PN5xx chips for control of Mifare Classic (1K) and CEPAS standard
Developed Android NFC control system for MiFareClassic and Ultralight C in Galaxy Nexus (using NXP NFC chipset)
Developed Android NFC control system for Ultralight C in Nexus 4
Our challenge: we want to control MiFareClassic 1K card in our POS machine (with NXP chip) and in new Android tablets (with Broadcom chip), we already have the installed card base and can not replace them.
- We know Nexus 4 has changed the NFC chip, now it can not read/write any Mifare classic card block except UID.
- Our code detects Mifare classic card as NfcA type. NfcA has a method called transceive(byte[] data) to Send raw NFC-A commands to the tag and receive the response.
- Our problem is we need to know what code to send to the device to read the UID, other people online say they can do it but no methodology can be found
Currently we always get an error: android.nfc.TagLostException: Tag was lost.
Thanks for your answer.
You can call getId()
on the Tag object in the Intent. This will return the ID of the tag (which, in the case of MIFARE Classic, may be a 4- or 7-byte unique ID, a random ID or a fixed non-unique 4-byte ID; depending on the exact MIFARE Classic product).
There is no need to call connect()
on NfcA
(and no possibility to do anything meaningful).
Please, note that this will not work on the Samsung Galaxy S4. That phone will not dispatch an NFC intent when a MIFARE tag is tapped. Instead, it will display an error message on the screen stating that the phone is incompatible with this tag and then ignore the tag.
UPDATE: On an S4 running Android 4.4 KitKat, you can use the NFC Reader Mode to get access to such details as card UID, also for MIFARE Classic tags.