views:

274

answers:

1

i m workin on mapview and put the marker when i click the marker it shows a bubble.

if i click that bubble it shows the toast perfectly

i want to start the activity there. then it shows an exception

this my code

@Override
protected boolean onBalloonTap(int index) {
try{
Activity a=new Activity();
a.startActivity(new Intent(a.getBaseContext(),BruConnect_Detail.class));
//      Toast.makeText(c, "onBalloonTap for overlay index " + index,
//              Toast.LENGTH_LONG).show();
}catch(Exception e){
Log.v(TAG,"error:"+e);
e.printStackTrace();
}
return true;
}

my logcat display shows:

03-04 23:53:13.311: VERBOSE/MyItemizedOverlay(713): error:java.lang.NullPointerException
03-04 23:53:13.322: WARN/System.err(713): java.lang.NullPointerException
03-04 23:53:13.331: WARN/System.err(713):     at android.content.ComponentName.<init>(ComponentName.java:75)
03-04 23:53:13.331: WARN/System.err(713):     at android.content.Intent.<init>(Intent.java:2551)
03-04 23:53:13.352: WARN/System.err(713):     at com.example.bruconnect.MyItemizedOverlay.onBalloonTap(MyItemizedOverlay.java:47)
03-04 23:53:13.352: WARN/System.err(713):     at com.example.bruconnect.BalloonItemizedOverlay$1.onTouch(BalloonItemizedOverlay.java:135)
03-04 23:53:13.373: WARN/System.err(713):     at android.view.View.dispatchTouchEvent(View.java:3705)
03-04 23:53:13.373: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:852)
03-04 23:53:13.382: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.392: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.402: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.402: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.411: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.424: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.431: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.462: WARN/System.err(713):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
03-04 23:53:13.474: WARN/System.err(713):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
03-04 23:53:13.482: WARN/System.err(713):     at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
03-04 23:53:13.482: WARN/System.err(713):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
03-04 23:53:13.502: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.502: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.512: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.525: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.525: WARN/System.err(713):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-04 23:53:13.525: WARN/System.err(713):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
03-04 23:53:13.533: WARN/System.err(713):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
03-04 23:53:13.542: WARN/System.err(713):     at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
03-04 23:53:13.552: WARN/System.err(713):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
03-04 23:53:13.552: WARN/System.err(713):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
03-04 23:53:13.562: WARN/System.err(713):     at  android.os.Handler.dispatchMessage(Handler.java:99)
03-04 23:53:13.562: WARN/System.err(713):     at android.os.Looper.loop(Looper.java:123)
03-04 23:53:13.562: WARN/System.err(713):     at android.app.ActivityThread.main(ActivityThread.java:4363)
03-04 23:53:13.581: WARN/System.err(713):     at java.lang.reflect.Method.invokeNative(Native Method)
03-04 23:53:13.581: WARN/System.err(713):     at java.lang.reflect.Method.invoke(Method.java:521)
03-04 23:53:13.591: WARN/System.err(713):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-04 23:53:13.601: WARN/System.err(713):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-04 23:53:13.601: WARN/System.err(713):     at dalvik.system.NativeStart.main(Native Method)

what s the problem . i think the problem in context value. any idea or suggestions to solve it.

thanks

A: 

The immediate bug is on line 47 in MyItemizedOverlay.java, according to the stack trace.

And, you can't just create a new Activity like that. You need a real Context (such as the activity containing the MapView, or the application context) in order to start an activity.

Also, a side comment: where is onBalloonTap defined? It doesn't seem to be a standard ItemizedOverlay method.

Roman Nurik