Frage

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);
        }


    }
}
War es hilfreich?

Lösung

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:

  • com.org.whatsaround.WhatsAroundMidlet.showLocationView() - within this method the exception is thrown.
  • gm.commandAction() - firing of the Command callback - i.e. entering your own code.
  • ez.gestureAction() - processing of the gesture within the maps-gesture.jar
  • com.nokia.mid.ui.gestures.GestureHandler.handleGestureEvent() - This is the Gesture handler created by the maps-gesture.jar which has been invoked due to the long press.
  • com.sun.midp.lcdui.DisplayEventListener.process() - this is passing events to all registered listeners, in your case this is a LONG PRESS event.
  • com.sun.midp.events.EventQueue.run() - underlying event loop (from the emulator perhaps?)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top