I'm developing an Android application that's using NFC. I have some NFC card with the following tech-list:
- android.nfc.tech.NfcA
- android.nfc.tech.MifareClassic
- android.nfc.tech.NdefFormatable
But I cannot format those tags using NdefFormatable.format(message)
. Instead, I get an IOException.
The code:
try {
NdefRecord[] records1 = { createRecord("000000") };
NdefMessage message1 = new NdefMessage(records1);
formatable.format(message1);
res = 1;
}
The stacktrace gave these logs:
W/System.err: java.io.IOException
W/System.err: at android.nfc.tech.NdefFormatable.format(NdefFormatable.java:131)
W/System.err: at android.nfc.tech.NdefFormatable.format(NdefFormatable.java:94)
at com.example.peng.nfcreadwrite.MainActivity.write(MainActivity.java:170)
W/System.err: at com.example.peng.nfcreadwrite.MainActivity.access$000(MainActivity.java:27)
at com.example.peng.nfcreadwrite.MainActivity$1.onClick(MainActivity.java:60)
at android.view.View.performClick(View.java:6877)
W/System.err: at android.widget.TextView.performClick(TextView.java:12651)
at android.view.View$PerformClick.run(View.java:26069)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
W/System.err: at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Maybe someone can give me something to look into, cause I'm fairly new into NFC on Android.
Edit
This is the screenshot I took using Mifare Classic Tool. It shows for sectors 4 to 8 that "no keys found(or dead sector)":