Do not call populate() until you are done adding items. Also, here is an example that does not crash -- perhaps you can find other places where your code differs from it:
http://github.com/commonsguy/cw-android/tree/master/Maps/NooYawk/ On Fri, Jul 2, 2010 at 3:48 AM, Pedro Teixeira <[email protected]> wrote: > This is my ItemizedOverlay Class: > public class mapOverlays extends ItemizedOverlay<OverlayItem> { > private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>(); > > public mapOverlays(Drawable defaultMarker) { > super(boundCenter(defaultMarker)); > // TODO Auto-generated constructor stub > } > > public void addOverlay(OverlayItem overlay) { > mOverlays.add(overlay); > populate(); > } > @Override > protected OverlayItem createItem(int i) { > return mOverlays.get(i); > } > @Override > public int size() { > return mOverlays.size(); > } > > public void draw(android.graphics.Canvas canvas, MapView mapView, boolean > shadow){ > super.draw(canvas, mapView, false); > } > > } > > And this is my code were I call it and which making my map to crash: > for (int j=0; j<gpItems.size();j++){ > GeoPoint Y = gpItems.get(j); > OverlayItem overlayPics = new OverlayItem(Y,"",""); > itemizedOverlay.addOverlay(overlayPics); > Y=null; > overlayPics=null; > } > mapOverlays.add(itemizedOverlay); > > On Jun 30, 2010, at 7:10 PM, Steve Howard wrote: > > Have you ensured you're calling ItemizedOverlay.populate() before adding the > overlay to the map view? > Steve > > On Tue, Jun 29, 2010 at 5:42 PM, Pedro Teixeira <[email protected]> > wrote: >> >> Hey there... >> >> My application using google maps was working just fine.. I left it for >> a while.. and suddenly out of the blue.. it crashes by just touching >> on the map... the only change I've done was to change a .png file for >> another image.. >> Anyway.. I get a NullPointerException.. on the debugger.. nd the >> logcat writes this errors: >> >> 06-30 01:39:16.756: ERROR/ActivityThread(619): Failed to find provider >> info for android.server.checkin >> 06-30 01:39:16.856: ERROR/ActivityThread(619): Failed to find provider >> info for android.server.checkin >> 06-30 01:39:23.546: ERROR/ActivityThread(738): Failed to find provider >> info for com.google.settings >> 06-30 01:39:23.566: ERROR/ActivityThread(738): Failed to find provider >> info for com.google.settings >> 06-30 01:39:23.606: ERROR/ActivityThread(738): Failed to find provider >> info for com.google.settings >> >> and more >> >> 06-30 01:39:23.606: ERROR/ActivityThread(738): Failed to find provider >> info for com.google.settings >> 06-30 01:39:27.527: ERROR/MapActivity(738): Couldn't get connection >> factory client >> 06-30 01:39:56.476: ERROR/AndroidRuntime(738): Uncaught handler: >> thread main exiting due to uncaught exception >> 06-30 01:39:56.627: ERROR/AndroidRuntime(738): >> java.lang.NullPointerException >> 06-30 01:39:56.627: ERROR/AndroidRuntime(738): at >> >> com.google.android.maps.ItemizedOverlay.getItemsAtLocation(ItemizedOverlay.java: >> 617) >> 06-30 01:39:56.627: ERROR/AndroidRuntime(738): at >> >> com.google.android.maps.ItemizedOverlay.getItemAtLocation(ItemizedOverlay.java: >> 586) >> 06-30 01:39:56.627: ERROR/AndroidRuntime(738): at >> >> com.google.android.maps.ItemizedOverlay.handleMotionEvent(ItemizedOverlay.java: >> 498) >> 06-30 01:39:56.627: ERROR/AndroidRuntime(738): at >> com.google.android.maps.ItemizedOverlay.onTouchEvent(ItemizedOverlay.java: >> 572) >> 06-30 01:39:56.627: ERROR/AndroidRuntime(738): at >> com.google.android.maps.OverlayBundle.onTouchEvent(OverlayBundle.java: >> 63) >> >> there's much more.. but i guess its something to do with the maps >> itself.. any help please? >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > > Pedro Teixeira > www.pedroteixeira.org > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

