Adding OverlayItems to MapView is reallyslow, how to make it faster? <p>In my app there is a MapView, and I add OverlayItems to it, <strong>about 500</strong>, <strong>but it will be more even thousands in the future...</strong></p> <p>My problem is: When I switch to this Activity, <strong>I got a massive 3-4 sec blackout</strong> then it switches properly and I can navigate and tap on the map.</p> <p>Some months ago when the app only contained 50-150 GeoPoints in the mapView there was no blackout. So i think something is wrong with my OverlayItem adding to the mapView, it really slows then the app.</p> <p>I add my GeoPoints with a simple cycle on Activity startup.</p> <p>What can i do to make this Activity <strong>faster and prevent the blackout?</strong></p> <p>EDIT:</p> <p>Thanks to comments, i just realized <strong>i call populate()</strong> after every <strong>addOverlay(MyOverlayItem myoverlay)</strong> function call.</p> <p>I edited the code, now after the cycle i call it only once by:</p> <pre><code>public void populateNow() { populate(); } </code></pre> <p>But i just got a nice null pointer exception with this... Any ideas?</p> <pre><code>11-12 15:54:03.398: E/MapActivity(1534): Couldn't get connection factory client 11-12 15:54:03.531: E/AndroidRuntime(1534): FATAL EXCEPTION: main 11-12 15:54:03.531: E/AndroidRuntime(1534): java.lang.NullPointerException 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.ItemizedOverlay.getIndexToDraw(ItemizedOverlay.java:211) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.ItemizedOverlay.draw(ItemizedOverlay.java:240) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.Overlay.draw(Overlay.java:179) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.MapView.onDraw(MapView.java:530) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.View.draw(View.java:6933) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.drawChild(ViewGroup.java:1646) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.drawChild(ViewGroup.java:1644) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.View.draw(View.java:6936) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.widget.FrameLayout.draw(FrameLayout.java:357) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.drawChild(ViewGroup.java:1646) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.View.draw(View.java:6936) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.widget.FrameLayout.draw(FrameLayout.java:357) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1904) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewRoot.draw(ViewRoot.java:1527) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewRoot.performTraversals(ViewRoot.java:1263) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewRoot.handleMessage(ViewRoot.java:1865) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.os.Handler.dispatchMessage(Handler.java:99) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.os.Looper.loop(Looper.java:123) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.app.ActivityThread.main(ActivityThread.java:3687) 11-12 15:54:03.531: E/AndroidRuntime(1534): at java.lang.reflect.Method.invokeNative(Native Method) 11-12 15:54:03.531: E/AndroidRuntime(1534): at java.lang.reflect.Method.invoke(Method.java:507) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 11-12 15:54:03.531: E/AndroidRuntime(1534): at dalvik.system.NativeStart.main(Native Method) </code></pre>