Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7527173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:03:12+00:00 2026-05-30T04:03:12+00:00

I have built off of the google api MapView demo. I’ve extended the MapView

  • 0

I have built off of the google api MapView demo.

I’ve extended the MapView class to create a “onPanListener” similar to:
How to catch that map panning and zoom are really finished?

I’ve also created a GroundOverlay class similar to:
Android google maps groundoverlay

I’m struggling to figure out why I sometimes get a ConcurrentModificationException. I suspect it might be because I end up with two timer triggered panlisteneres that execute and cause concurrent access issues on the overlay list. However, I can’t tell if that is the problem or not. I have tried adding synchronized (mapview.getOverlay()) {} on any code that removes or adds anything to the overlay list.

I have my stack trace listed below, but I’m not exactly sure what to make of it. It looks like the exception maybe starts in my GroundOverlay class from the draw method (but I’m not sure). When I remove the groundoverlay, I don’t think I get the ConcurrentModificationException — bit tough to tell since it is an intermittent thing.

The stack trace does seem to suggest it is coming from the mapview.draw method. I thought maybe I could override that method in my mapview subclass and try and synchronize that, but unfortunately, draw is final in the parent class. Synchronizing dispatchDraw doesn’t seem to help.

Is there a better way to debug something like this? Maybe get some more information about the exception somehow — just knowing what line of my code throws it would be enormously helpful.

I have tried synchronizing

02-12 10:59:31.995: E/AndroidRuntime(24649): FATAL EXCEPTION: main

02-12 10:59:31.995: E/AndroidRuntime(24649): java.util.ConcurrentModificationException
02-12 10:59:31.995: E/AndroidRuntime(24649):    at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:576)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:44)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at com.google.android.maps.MapView.onDraw(MapView.java:530)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.View.draw(View.java:6880)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.View.draw(View.java:6883)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.widget.FrameLayout.draw(FrameLayout.java:357)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.View.draw(View.java:6883)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.widget.FrameLayout.draw(FrameLayout.java:357)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2106)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.ViewRoot.draw(ViewRoot.java:1562)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.ViewRoot.performTraversals(ViewRoot.java:1298)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1911)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.os.Looper.loop(Looper.java:130)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at android.app.ActivityThread.main(ActivityThread.java:3821)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at java.lang.reflect.Method.invokeNative(Native Method)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at java.lang.reflect.Method.invoke(Method.java:507)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-12 10:59:31.995: E/AndroidRuntime(24649):    at dalvik.system.NativeStart.main(Native Method)

Here is my OnChangeListener. Based on the comment, it sounds like clearing and rewriting the overlays isn’t the best option. Maybe, instead of trying to get the onpan event from my MapView class, I should really be getting it from my extended OverlayItem class? I can probably try that.

mMapView.setOnChangeListener(new MyMapView.OnChangeListener() {

        @Override
        public void onChange(Metars metar, Pireps pirep, MyMapView view, GeoPoint newCenter, GeoPoint oldCenter,
                int newZoom, int oldZoom) {

            //metar.addOverlays(view);
            if (view.updatingOverlay == false) {
                view.updatingOverlay = true;
                synchronized (view.getOverlays() ) {
                    view.getOverlays().clear();
                    view.getOverlays().add(view.getRadar());
                }
                metar.addOverlays(view);
                pirep.addOverlays(view);
                view.postInvalidate();
                view.updatingOverlay = false;
            }


        }
    });

}

Here’s the code for the xxx.addOverlays(view)

public void addOverlays(MyMapView mapView) {

          // do a bunch of stuff and get overlays ready to add
    List<Overlay> mapOverlays = mapView.getOverlays();

    // add them to my subclass of ItemizedOverlay

    synchronized(mapOverlays) {
    if (itemizedoverlay.size() > 0 )
        mapOverlays.add(itemizedoverlay);
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:03:13+00:00Added an answer on May 30, 2026 at 4:03 am

    After reading through Android 2.1 GoogleMaps ItemizedOverlay ConcurrentModificationException more thoroughly, I came to the conclusion that my issue was the fact that I was launching a new thread for the timer which added and removed overlay items, which would intermittently cause the concurrentacccessexception.

    I ended up putting the code modifying the overlays inside an Activity.runOnUiThread(…) and haven’t seen the problem since.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iphone app that I built based off a tutorial (for a
I have built a MS Access 2007 application that can create reports files in
I have built an MSI that I would like to deploy, and update frequently.
I have built an application in C# that I would like to be optimized
I have built a number of asp.net servercontrols into a class library, & I
I have built a .dll under WinXP that claims it can't find DWMAPI.DLL when
I have built an application that uses SQL Express 2005 and I want to
i have built a custom class, which i call from a frame script. the
Thanks in advance! I have a simple mysql and php blog that I built
i have built a reporting services report off SQL server 2005 and am having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.