rt,寫的代碼如下
public static void writeTag(Tag tag) {
MifareUltralight ultralight = MifareUltralight.get(tag);
try {
ultralight.connect();
ultralight.writePage(4, "1".getBytes(Charset.forName("utf-8")));
// ultralight.writePage(5, "efgh".getBytes(Charset.forName("US-ASCII")));
// ultralight.writePage(6, "ijkl".getBytes(Charset.forName("US-ASCII")));
// ultralight.writePage(7, "mnop".getBytes(Charset.forName("US-ASCII")));
ultralight.close();
} catch (IOException e) {
Log.e("NFC WRITE ERROR", "IOException while closing MifareUltralight...", e);
} finally {
try {
ultralight.close();
} catch (IOException e) {
Log.e("NFC WRITE ERROR", "IOException while closing MifareUltralight...", e);
}
}
}但是一執行就會產生如下例外:
WRITE ERROR: IOException while closing MifareUltralight...
java.io.IOException: Transceive failed
at android.nfc.TransceiveResult.getResponseOrThrow(TransceiveResult.java:52)
at android.nfc.tech.BasicTagTechnology.transceive(BasicTagTechnology.java:151)
at android.nfc.tech.MifareUltralight.writePage(MifareUltralight.java:193)
at com.ssl.hitpatrol.utils.NfcMsgParser.writeTag(NfcMsgParser.java:171)
at com.ssl.hitpatrol.activity.MainActivity$override.onNewIntent(MainActivity.java:59)
at com.ssl.hitpatrol.activity.MainActivity$override.access$dispatch(MainActivity.java)
at com.ssl.hitpatrol.activity.MainActivity.onNewIntent(MainActivity.java:0)
at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1218)
at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1230)
at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2677)
at android.app.ActivityThread.performNewIntents(ActivityThread.java:2689)
at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2698)
at android.app.ActivityThread.access$1600(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1542)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
uj5u.com熱心網友回復:
自己頂一下啊uj5u.com熱心網友回復:
你好 解決了么uj5u.com熱心網友回復:
是不是寫入塊鎖定了轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/23750.html
標籤:Android
上一篇:關于QTBALEWIDGET 的 右側滑動條QSCROLLBAR, MAX 與 ROWS不同問題
下一篇:手機息屏后網路連接問題
