在长时间单击地图时,我试图显示lwuit表单,但我得到了以下错误
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)代码是
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);
}
}
}发布于 2013-07-26 07:28:53
可以从堆栈跟踪中看到异常,异常在方法showLocationView()中抛出,NullPointerException可能是由于方法调用中的一个参数(country、phoneNumber、firstName、lastName等)造成的。传入未初始化的对象。
如果coord有问题,您可以按以下方式检查:
if (c == LONG_TOUCH) {
GeoCoordinate coord = longTouch.getTouchAt();
System.out.println(coord);
}否则,您就只能靠自己了,因为您还没有解释代码中的country、phoneNumber、firstName、lastName等是如何和在何处实际填充的。
如果堆栈跟踪中的函数名称没有混淆,则可以确定以下内容:
com.org.whatsaround.WhatsAroundMidlet.showLocationView() -在此方法中抛出异常。gm.commandAction() -触发Command回调-即输入您自己的代码。ez.gestureAction() -处理maps-gesture.jar中的手势com.nokia.mid.ui.gestures.GestureHandler.handleGestureEvent() --这是由maps-gesture.jar创建的手势处理程序,由于长按而被调用。com.sun.midp.lcdui.DisplayEventListener.process() --这是将事件传递给所有已注册的侦听器,在您的示例中,这是一个长新闻事件。com.sun.midp.events.EventQueue.run() -基础事件循环(可能来自模拟器?)https://stackoverflow.com/questions/17837290
复制相似问题