Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
250 views
in Technique[技术] by (71.8m points)

java.lang.nullpointerexception in j2me

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()); 
        } 
 }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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) + "]"); 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...