0
我正在做一個NFC實驗,我需要寫入MIFARE Classic標籤,但它給了我一個Exception,因爲它需要16個字節。這聽起來樣noobish的,但我已經試過一切,它仍然給了我同樣的異常:如何從Java字符串中獲取正好16個字節
Caused by: java.lang.IllegalArgumentException: must write 16-bytes
at android.nfc.tech.MifareClassic.writeBlock(MifareClassic.java:446)
at com.kaissersoft.cartracker.MainActivity$1$1.doInBackground(MainActivity.java:80)
at com.kaissersoft.cartracker.MainActivity$1$1.doInBackground(MainActivity.java:72)
at android.os.AsyncTask$2.call(AsyncTask.java:297)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
一個代碼,我用件:
mifare.connect();
//DO STUFF
mifare.writeBlock(4, "CAR 100000000000".getBytes(Charset.forName("UTF-16LE")));