伙计们
很多天以来,我都面临着非常奇怪的问题。我正在尝试经常更新覆盖。因此,有时当我触摸地图时会收到“java.util.ConcurrentModificationException”,或者有时会在地图尝试更新叠加层时收到“java.util.ConcurrentModificationException”但我没有找到完美的线条,该错误即将到来。
02-17 14:56:01.621: W/dalvikvm(3653): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-17 14:56:01.631: E/AndroidRuntime(3653): FATAL EXCEPTION: main
02-17 14:56:01.631: E/AndroidRuntime(3653): java.util.ConcurrentModificationException
02-17 14:56:01.631: E/AndroidRuntime(3653): at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:576)
02-17 14:56:01.631: E/AndroidRuntime(3653): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:41)
02-17 14:56:01.631: E/AndroidRuntime(3653): at com.google.android.maps.MapView.onDraw(MapView.java:530)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.View.draw(View.java:6880)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.View.draw(View.java:6883)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.widget.FrameLayout.draw(FrameLayout.java:357)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.View.draw(View.java:6883)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.widget.FrameLayout.draw(FrameLayout.java:357)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.View.draw(View.java:6883)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.widget.FrameLayout.draw(FrameLayout.java:357)
02-17 14:56:01.631: E/AndroidRuntime(3653): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1862)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewRoot.draw(ViewRoot.java:1522)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewRoot.performTraversals(ViewRoot.java:1258)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.os.Looper.loop(Looper.java:130)
02-17 14:56:01.631: E/AndroidRuntime(3653): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-17 14:56:01.631: E/AndroidRuntime(3653): at java.lang.reflect.Method.invokeNative(Native Method)
02-17 14:56:01.631: E/AndroidRuntime(3653): at java.lang.reflect.Method.invoke(Method.java:507)
02-17 14:56:01.631: E/AndroidRuntime(3653): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-17 14:56:01.631: E/AndroidRuntime(3653): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-17 14:56:01.631: E/AndroidRuntime(3653): at dalvik.system.NativeStart.main(Native Method)
我正在使用气球叠加
我认为它会引发错误,"mapview.getOverlay()"
因为它在 1 秒内调用了 4-5 次..
谢谢,
CapDroid
这是代码流..我的线程代码....
Thread connection = new Thread(){
public void run() {
try {
while (my condition)
{
try
{
//This method should be call every seconds
updateMethod();
}
catch (Exception e)
{
e.printStackTrace();
break;
}
}
}
catch (Exception e)
{
}
}
};
这是我的更新方法(); 在此代码中,hashmapOverlay 是 HashMap,如下所示
public static Map<String,MyItemizedOverlay> hashmapOverlay;
public void updateMethod()
{
if(hashmapOverlay.containsKey(id))
{
mapview.getOverlays().remove(hashmapOnlineFriendsOverlay.get(id));
}
MyItemizedOverlay mMyItemizedOverlay = new MyItemizedOverlay(drawable, mapview);
OverlayItem overlayItem = new OverlayItem(gp,title ,snippet);
mMyItemizedOverlay.addOverlay(overlayItem);
hashmapOverlay.put(id, mMyItemizedOverlay);
addOverlayMethod(mActivity, mapView, mMyItemizedOverlay);
}
这是我的 addOverlayMethod
addOverlayMethod(Activity mActivity, final MapView mapView, final Object mObject)
{
mActivity.runOnUiThread(new Runnable(){
@Override
public void run()
{
try {
MyItemizedOverlay overlay = (MyItemizedOverlay) mObject;
mapView.getOverlays().add(overlay);
} catch (Exception e)
{}
}
});
}