我有一個方法可以在水龍頭上創建彈出式對話框,稱爲onBalloonTap
,我試圖在另一個類pip
中調用CallPopup()
。我究竟做錯了什麼?我不應該通過方法調用intent嗎?我的目標是在調用onBalloonTap
時啓動另一項活動。有一個更好的方法嗎?Android從另一個類中的方法調用一個Intent
在pip
public void CallPopup()
{ Log.i("CallPopup", "Started CallPopup");
startActivity(intent);
finish();
}
CallPopUp()
從onBalloonTap
被稱爲另一個類
protected boolean onBalloonTap(int index, OverlayItem item) {
Toast.makeText(c, "onBalloonTap for overlay index " + index,
Toast.LENGTH_LONG).show();
pip pipinst =new pip();
pipinst.CallPopup();
return true;
}
我得到這個日誌:
05-04 22:33:41.022: ERROR/AndroidRuntime(704): FATAL EXCEPTION: main
05-04 22:33:41.022: ERROR/AndroidRuntime(704): java.lang.NullPointerException
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.app.Activity.startActivityForResult(Activity.java:2817)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.app.Activity.startActivity(Activity.java:2923)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at com.appname.pip.pip.CallPopup(pip.java:192)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at com.appname.pip.MyItemizedOverlay.onBalloonTap(MyItemizedOverlay.java:67)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at com.readystatesoftware.mapviewballoons.BalloonItemizedOverlay$1.onTouch(BalloonItemizedOverlay.java:203)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.view.View.dispatchTouchEvent(View.java:3762)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:897)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.os.Handler.dispatchMessage(Handler.java:99)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.os.Looper.loop(Looper.java:123)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at java.lang.reflect.Method.invokeNative(Native Method)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at java.lang.reflect.Method.invoke(Method.java:521)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-04 22:33:41.022: ERROR/AndroidRuntime(704): at dalvik.system.NativeStart.main(Native Method)
05-04 22:33:41.102: WARN/ActivityManager(38): Force finishing activity com.appname.pip/.pip
05-04 22:33:41.952: WARN/ActivityManager(38): Activity pause timeout for HistoryRecord{43f680f0 com.appname.pip/.pip}