Teja
Teja

Reputation: 104

how to solve FATAL EXCEPTION: Timer-11 in android?

here is the code for exception::

if (getZoomLevel() != last_zoom)
 {
 // if computeScroll called before timer counts down we should drop it and start it over again
   zoom_event_delay_timer.cancel();
   zoom_event_delay_timer = new Timer();
   Log.v("last_zoom","last_zoom");
  zoom_event_delay_timer.schedule(new TimerTask()
  {
   @Override
  public void run()
  {
      zoom_change_listener.onZoomChange(_this, getZoomLevel(), last_zoom);
       Log.v("last_zoom","last_zoom"+last_zoom);
       last_zoom = getZoomLevel();
       Log.v("last_zoom","last_zoom");
   }
  }, events_timeout);
}

and the Error:

01-05 12:24:50.791: ERROR/AndroidRuntime(11132): FATAL EXCEPTION: Timer-11
    01-05 12:24:50.791: ERROR/AndroidRuntime(11132): java.util.ConcurrentModificationException
    01-05 12:24:50.791: ERROR/AndroidRuntime(11132):     at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
    01-05 12:24:50.791: ERROR/AndroidRuntime(11132):     at com.bluepal.android.parkable.Prakablescreen.onRegionChange(Prakablescreen.java:1028)
    01-05 12:24:50.791: ERROR/AndroidRuntime(11132):     at com.bluepal.android.parkable.Prakablescreen$14.onPanChange(Prakablescreen.java:467)
    01-05 12:24:50.791: ERROR/AndroidRuntime(11132):     at com.bluepal.android.parkable.EnhancedMapView$2.run(EnhancedMapView.java:126)
    01-05 12:24:50.791: ERROR/AndroidRuntime(11132):     at java.util.Timer$TimerImpl.run(Timer.java:289)

Upvotes: 1

Views: 3186

Answers (3)

Peter Parker
Peter Parker

Reputation: 26

the problem here seems to be that you are calling the UI thread from another thread (in this case the timer). I found these sites for explanation and solving the problem (i used a handler).

Upvotes: 1

mdelolmo
mdelolmo

Reputation: 6447

From the error it seems that you are trying to modify an arraylist while iterating over it

If 100rabh is right and you're not modifying your list though an iterator, maybe you can use a CopyOnWriteArrayList, which is ThreadSafe.

Upvotes: 0

100rabh
100rabh

Reputation: 6186

Please supply some source code .

From the error it seems that you are trying to modify an arraylist while iterating over it.If that is the case , use a temporary container for the arraylist & after all modifications, store this temporary arraylist to your arraylist .

Upvotes: 1

Related Questions