0

In the HelloMapView tutorial, the map seems to load fine, I can see maps, and also I can see the mark of Mexico that the example gives.

But, when I click on the Mexico mark, my application crashes, with the message

Android application crash

I think that I know what the problem is but I don't know how to solve it:

In step 7, the tutorial says this:

Now set up the ability to handle touch events on the overlay items. First, you're going to need a reference to the application Context as a member of this class. So add Context mContext as a class member, then initialize it with a new class constructor:

public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
  super(defaultMarker);
  mContext = context;
}

Okay, but in the main tutorial class, when it declares this class, it doesn't give it the context:

HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);

I tried to do this: new HelloItemizedOverlay(drawable, getApplicationContext());

but that does not work, the map appears without the Mexico mark.

Does anyone have an idea of where I went wrong?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Paul
  • 1
  • 1
  • 5
  • 1
    Use `adb logcat`, DDMS, or the DDMS perspective in Eclipse to look at LogCat and examine the stack trace associated with your "android application crash". Also, do not use `getApplicationContext()` for GUI operations -- use `this` instead. – CommonsWare Oct 11 '10 at 20:33

1 Answers1

0

@CommonsWare wrote:

Use adb logcat, DDMS, or the DDMS perspective in Eclipse to look at LogCat and examine the stack trace associated with your "android application crash". Also, do not use getApplicationContext() for GUI operations -- use this instead.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129