I was having the following error
Skipped 40 frames! The application may be doing too much work on its main thread.
Researched about it... Made sure everything started in new threads as much as possible with Runnables. But kept getting the error. I almostly commented all my code and still got it when I started a new activity. Then I commented this mapfragment from my first activity and there error was gone. So the error is caused by following piece of code:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="200dp"
/>
I got this from Google Maps API for Android docs... Kind of weird it's not optimised. How can I make sure the error disappears? Can I delay the load of the mapFragment?
Once I opened the Activity once... and reopen it again the warning is gone because it's in the memory already.. but I'd like to have the best optimised app possible.
To avoid confusion It's the setContentView that is causing delay because the mapFragment is loaded in this function. The delay causes a warning to be thrown. My question: how can I speed up the setContentView, so the mapFragment is pre-loaded or loads after the activity is opened.