How Can i read mifare classic 1k Card by Nexus s

user556615 picture user556615 · Apr 14, 2011 · Viewed 9.2k times · Source

am working with NFC Android programming and I want to read Mifare Classic cards. Does anybody know how to read the sectors off such a card?

Authentication method returns true which means that authentication is done. After authentication, sector should be ready for any IO action but whenever i use readBlock() method or transceive() method, I get exception with IOException("transceive failed"). I can not find any example which uses the Mifare Classic, so i want to know if it is possible to read the Mifare Classic with this API or not.

My code like this boolean success = m1tag.authenticateSectorWithKeyB(0,MifareClassic。KEY_DEFAULT) int index = m1tag.sectorToBlock(0) byte[] content = m1tag.readBlock(index)

success is true,but when i read content from card,throw IOException("transceive failed")

Answer

Krzysztof Dubrowski picture Krzysztof Dubrowski · Feb 17, 2012

You won't be able to readBlock() or writeBlock() after using authenticateSectorWithKeyB(). If it is a new tag with default access bits access to the tag will be blocked. If the access conditions have be changed then readBlock() and writeBlock() will throw an exception. You will have to perform reading of the tag using KeyA authentication.