NullPointerException when itemizedOverlay doesn't contain any Overlay item

Yesterday when I was working in Android, I got a strange exception. I am adding an ItemizedOverlay to google map. I am adding OverlayItem to the ItemizedOverlay when one condition is true. But sometimes, this condition is false and not adding any OverlayItem to the ItemizedOverlay. But still adding the ItemizedOverlay to google maps. At this time, I am getting null pointer exception. First I didn't get what is going wrong. Then after some googling, I came to know we can't add ItemizedOverlay to google map when there is no OverlayItem in the Overlay. So be careful when adding empty ItemizedOverlay to google maps. I was working in API level 10. I am not sure whether this problem is in future versions.

Popular posts from this blog

Open Gallery and get the selected image in appplication

Dismiss or Cancel dialog by swipe gesture

AlarmManager and Notification in Android