Open brennydoogles opened 11 years ago
i'm getting the same error. when i traced the code, the Line states that "Mad1 mad1 = new Mad1(null, null);"
which is Mad1 extends AbstractMad and AbstractMad has this constructor.
public AbstractMad(MfClassicReaderWriter readerWriter, MadKeyConfig keyConfig) { if (keyConfig == null) throw new IllegalArgumentException("keyConfig cannot be null"); this.readerWriter = readerWriter; this.keyConfig = keyConfig; this.memoryLayout = readerWriter.getMemoryLayout(); }
so, if when you run NdefReaderDemo and NdefWriter demo, they will really throw you to that exception.
i dont really know the work around here i just traced the code and i can say that NdefReader and NdefWriter Demos will not work how many times you will try.
is there a way to make this work @grundid ?
I know this is many years late, but for others banging their head against the wall: It's a deprecated API. The new API usage looks like this (in Kotlin):
val adapter = NfcAdapter(getAvailableTerminal(), TerminalMode.INITIATOR, object : TagScannerListener{
override fun onScanningEnded() {
println("onScanningEnded")
}
override fun onScanningFailed(throwable: Throwable?) {
println("onScanningFailed")
}
override fun onTagHandingFailed(throwable: Throwable?) {
println("onTagHandingFailed")
}
})
adapter.registerTagListener(MfClassicNfcTagListener(object : NdefOperationsListener{
override fun onNdefOperations(ndefOperations: NdefOperations) {
val records = ndefOperations.readNdefMessage()
for(record in records){
println("Record found: " + record.toString())
}
}
}))
TagScannerListener
Thank you this solution solved my problem