j2me 中的 java.lang.nullpointerexception [英] java.lang.nullpointerexception in j2me
本文介绍了j2me 中的 java.lang.nullpointerexception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个读取 mifare 卡的应用程序,但是当我通过 APDU 时,在模拟器java.lang.nullpointerexception"上发生错误.在我通过 APDU 之后,我成功检测到 ISO14443_CARD
I am writing an application for read the mifare card,but when I pass the APDU the error occur that on emulator "java.lang.nullpointerexception".I have successfully detect the ISO14443_CARD after that I pass the APDU like
if (tp.hasTargetType(TargetType.ISO14443_CARD)){
form.append("Target is ISO14443_CARD
");
try {
static byte[] APDU_AUTH1 = { (byte) 0xff, (byte) 0x86, (byte) 0x00, (byte) 0x00, (byte) 0x05,(byte)0x01,(byte)0x00,(byte)0xfc,(byte)0x60,(byte)0x00};
static byte[] STATUS_BYTE = {(byte)0x90,(byte)0x00};
if(STATUS_BYTE == iso14443.exchangeData(APDU_LOAD_KEY))
{
String value1 = new String("Hai!");
textfield1.setString(value1);
form.append(textfield1);
}
else
{
String value1 = new String("Hello!");
textfield1.setString(value1);
form.append(textfield1);
}
}
catch (Exception ex) {
form.append(ex.toString());
}
}
推荐答案
iso14443
或 textfield1
对象可能为空.
Either of iso14443
or textfield1
objects is likely null.
通过您调试事物的方式(顺便说一句,我的恭喜),您可以按如下方式记录检查:
With the way you debug things (quite smart BTW, my congratulations), you could log the checks about as follows:
form.append("
iso14443 is null: [" + (iso14443 == null)
+ "],
textfield1 is null: [" + (textfield1 == null) + "]");
这篇关于j2me 中的 java.lang.nullpointerexception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文