Question

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\n");

 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()); 
        } 
 }
Was it helpful?

Solution

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("\n\n iso14443 is null: [" + (iso14443 == null)
        + "],\n textfield1 is null: [" + (textfield1 == null) + "]"); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top