我有一個TabHostActivity中的MapsActivity,我在地圖上放置了一個自定義的ItemizedOverlay來顯示自定義的OverlayItems。Android:NullPointer之後試圖做一個意圖後onTab on ItemizedOverly
以我ItemizedOverlay類的onTab方法如下所示
@Override
protected boolean onTap(int index) {
listener.onPoiTap(this.poiList.get(index));
return true;
}
其中聽者變量是一個自定義onTabListener其在地圖活動實現的:後
@Override
public void onPoiTap(PointOfInterest poi) {
Intent intent = new Intent();
intent.setClass(getParent(), PointOfInterestActivity.class);
ActivityStack activityStack = (ActivityStack) this.getParent();
activityStack.push(new Date().getTime() + "", intent);
// Toast.makeText(this, "Title: " + poi.getTitle(), Toast.LENGTH_SHORT).show();
}
的吐司評論的作品,並顯示正確的標題,但意圖的呼叫使應用程序崩潰,並顯示日誌沒有任何引用我的代碼:
I/InputReader(2284): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.749 ]
I/InputDispatcher(2284): Delivering touch to current input target: action: 0x0
I/InputDispatcher(2284): Delivering touch to current input target: action: 0x0
I/InputDispatcher(2284): Delivering touch to current input target: action: 0x0
I/InputReader(2284): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=]
I/InputDispatcher(2284): Delivering touch to current input target: action: 0x1
I/InputDispatcher(2284): Delivering touch to current input target: action: 0x1
I/InputDispatcher(2284): Delivering touch to current input target: action: 0x1
E/InputEventReceiver(22509): Exception dispatching input event.
E/MessageQueue-JNI(22509): Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI(22509): java.lang.NullPointerException
E/MessageQueue-JNI(22509): at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:548)
E/MessageQueue-JNI(22509): at com.google.android.maps.MapView.onTouchEvent(MapView.java:683)
E/MessageQueue-JNI(22509): at android.view.View.dispatchTouchEvent(View.java:7337)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2410)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2145)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2109)
E/MessageQueue-JNI(22509): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1462)
E/MessageQueue-JNI(22509): at android.app.Activity.dispatchTouchEvent(Activity.java:2472)
E/MessageQueue-JNI(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2057)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2109)
E/MessageQueue-JNI(22509): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1462)
E/MessageQueue-JNI(22509): at android.app.Activity.dispatchTouchEvent(Activity.java:2472)
E/MessageQueue-JNI(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2057)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/MessageQueue-JNI(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/MessageQueue-JNI(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2109)
E/MessageQueue-JNI(22509): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1462)
E/MessageQueue-JNI(22509): at android.app.Activity.dispatchTouchEvent(Activity.java:2472)
E/MessageQueue-JNI(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2057)
E/MessageQueue-JNI(22509): at android.view.View.dispatchPointerEvent(View.java:7520)
E/MessageQueue-JNI(22509): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3374)
E/MessageQueue-JNI(22509): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3306)
E/MessageQueue-JNI(22509): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4400)
E/MessageQueue-JNI(22509): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4378)
E/MessageQueue-JNI(22509): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4482)
E/MessageQueue-JNI(22509): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
E/MessageQueue-JNI(22509): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MessageQueue-JNI(22509): at android.os.MessageQueue.next(MessageQueue.java:125)
E/MessageQueue-JNI(22509): at android.os.Looper.loop(Looper.java:124)
E/MessageQueue-JNI(22509): a
D/AndroidRuntime(22509): Shutting down VM
W/dalvikvm(22509): threadid=1: thread exiting with uncaught exception (group=0x410662a0)
E/AndroidRuntime(22509): FATAL EXCEPTION: main
E/AndroidRuntime(22509): java.lang.NullPointerException
E/AndroidRuntime(22509): at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:548)
E/AndroidRuntime(22509): at com.google.android.maps.MapView.onTouchEvent(MapView.java:683)
E/AndroidRuntime(22509): at android.view.View.dispatchTouchEvent(View.java:7337)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2410)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2145)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2109)
E/AndroidRuntime(22509): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1462)
E/AndroidRuntime(22509): at android.app.Activity.dispatchTouchEvent(Activity.java:2472)
E/AndroidRuntime(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2057)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2109)
E/AndroidRuntime(22509): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1462)
E/AndroidRuntime(22509): at android.app.Activity.dispatchTouchEvent(Activity.java:2472)
E/AndroidRuntime(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2057)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2416)
E/AndroidRuntime(22509): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
E/AndroidRuntime(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2109)
E/AndroidRuntime(22509): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1462)
E/AndroidRuntime(22509): at android.app.Activity.dispatchTouchEvent(Activity.java:2472)
E/AndroidRuntime(22509): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2057)
E/AndroidRuntime(22509): at android.view.View.dispatchPointerEvent(View.java:7520)
E/AndroidRuntime(22509): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3374)
E/AndroidRuntime(22509): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3306)
E/AndroidRuntime(22509): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4400)
E/AndroidRuntime(22509): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4378)
E/AndroidRuntime(22509): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4482)
E/AndroidRuntime(22509): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
E/AndroidRuntime(22509): at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime(22509): at android.os.MessageQueue.next(MessageQueue.java:125)
E/AndroidRuntime(22509): at android.os.Looper.loop
D/dalvikvm(22509): GC_CONCURRENT freed 1205K, 21% free 22090K/27719K, paused 5ms+4ms, total 51ms
D/dalvikvm(2284): GC_FOR_ALLOC freed 2199K, 46% free 32415K/59399K, paused 119ms, total 119ms
E/Watchdog(2284): [email protected] 388
任何想法我的代碼有什麼問題? 謝謝
我猜ActivityStack activityStack爲null,你應該看看這個視頻關於如何從eclipse調試android應用程序:http://www.youtube.com/watch?v = jqHYbm9e05A – petey
不,我已經檢查過。並感謝視頻,但我很清楚調試... – Elias