Note that there are some explanatory texts on larger screens.

plurals
  1. POopen different activities from map overlays
    primarykey
    data
    text
    <p>I am a very little experienced android programmer.</p> <p>I have a list activity and each list item opens a new activity. There is a Map in the app where it shows balloon overlays of the locations. There are, say 4 locations, when i click any of the balloon overlay i need the activity of the corresponding index. Eg: If i click on the balloon with index = 1, i need to display the 1st item of the list in an activity.</p> <p>I am currently using the code below.</p> <pre><code>@Override protected boolean onBalloonTap(int index, OverlayItem item) { Toast.makeText(c, "onBalloonTap for overlay index " + index, Toast.LENGTH_LONG).show(); int index1 = index; Intent i = new Intent(c,FestivalEvents.class); i.putExtra("banner", "index1"); c.startActivity(i); return true; } </code></pre> <p>I am catching the intent in another activity, i.e. FestivalEvents.class as below</p> <pre><code>Bundle eventExtra = getIntent().getExtras(); if(eventExtra!=null){ int position = eventExtra.getInt("banner"); Log.i("banner", "" + position); switch(position){ case 0: Toast.makeText(mContext, ""+ position, Toast.LENGTH_LONG).show();setUpDesc(position);break; case 1:Toast.makeText(mContext, ""+ position,Toast.LENGTH_LONG).show();setUpDesc(position);break; case 2:Toast.makeText(mContext, ""+ position, Toast.LENGTH_LONG).show();setUpDesc(position);break; case 3:Toast.makeText(mContext, ""+ position, Toast.LENGTH_LONG).show();setUpDesc(position);break; } } </code></pre> <p>the app crashes with a null pointer exception with this code. I hope my code is proper in receiving intents. Or may be i'm wrong in handling the recieving intent. I am having big time solving this. Can anybody please tell me where i may have gone wrong?</p> <p><strong>EDIT</strong> my logcat:</p> <p><code>11-02 18:45:38.858: ERROR/AndroidRuntime(21168): FATAL EXCEPTION: main 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sysponent.bedford/com.sysponent.bedford.FestivalEvents}: java.lang.NullPointerException 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at android.os.Handler.dispatchMessage(Handler.java:99) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at android.os.Looper.loop(Looper.java:130) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at android.app.ActivityThread.main(ActivityThread.java:3687) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at java.lang.reflect.Method.invokeNative(Native Method) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at java.lang.reflect.Method.invoke(Method.java:507) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168):at dalvik.system.NativeStart.main(Native Method) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): Caused by: java.lang.NullPointerException 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at com.sysponent.bedford.FestivalEvents.onCreate(FestivalEvents.java:239) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 11-02 18:45:38.858: ERROR/AndroidRuntime(21168):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) </code></p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload