java-mehere-apilwuit-form

Switching from HereMap to lwuit form


Am trying to display a lwuit form when the map is long clicked but I get the following error

java.lang.NullPointerException

at bw.a(), bci=1
at bw.<init>(), bci=6
at bt.<init>(), bci=10
at by.<init>(), bci=48
at bj.a(), bci=10
at fv.<init>(), bci=54
at ex.<init>(), bci=11
at ed.<init>(), bci=33
at com.org.whatsaround.WhatsAroundMidlet.showLocationView(), bci=17
at gm.commandAction(), bci=80
at b.a(), bci=59
at v.b(), bci=10
at c.d(), bci=6
at ez.gestureAction(), bci=237
at com.nokia.mid.ui.gestures.GestureHandler.handleGestureEvent(), bci=60
at com.sun.midp.lcdui.DisplayEventListener.process(), bci=421
at com.sun.midp.events.EventQueue.run(), bci=182
at java.lang.Thread.run(Thread.java:661)

The code is

public void commandAction(Command c, Displayable d) {
        if (c == LONG_TOUCH) {

            GeoCoordinate coord = longTouch.getTouchAt();

            WhatsAroundMidlet.getInstance().showLocationView(country, phoneNumber, firstName, lastName, pTitle, pCategory, backListener, profilePic, coord);
        }


    }
}

Solution

  • Can be seen from your stack trace, the exception is thrown in your code in the method showLocationView(), the NullPointerException is probably due to one of the parameters in the method call (country, phoneNumber, firstName, lastName,etc.) passing in a object which has not been initialised.

    If coord is at fault, you could check this as follows:

     if (c == LONG_TOUCH) {
          GeoCoordinate coord = longTouch.getTouchAt();
          System.out.println(coord);
     }
    

    Otherwise you are on your own since you haven't explained how and where in your code country, phoneNumber, firstName, lastName,etc. are actually populated.

    Where the names of the functions in the stack trace are un-obfuscated, you can ascertain the following: