Buongiorno,
sto cercando di creare un'applicazione dove possa scrivere sui tag MIFARE, però mi sono un po arenato.
Il mio codice è
1
2mytag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
3try {
4MifareClassic mfc = MifareClassic.get(mytag);
5boolean auth = false;
6mfc.connect();
7auth = mfc.authenticateSectorWithKeyA(0,MifareClassic.KEY_DEFAULT);
8if (auth) {
9
10String text = "Hello, World!";
11byte[] value = text.getBytes();
12byte[] toWrite = new byte[MifareClassic.BLOCK_SIZE];
13
14for (int i=0; i<MifareClassic.BLOCK_SIZE; i++) {
15if (i < value.length) toWrite[i] = value[i];
16else toWrite[i] = 0;
17}
18
19mfc.writeBlock(2, toWrite);
20show("");
21
22}
23} catch (IOException e) {
24show("errore");
25}
26
e mi da il seguente errore
Java.io.IOException: Transceive failed
Ho provato a "googlare un po" ma non sono riuscito a trovare la soluzione, qualcuno sa cosa sbaglio?
Grazie