1

I have a mapactivity and when I switch over to it it takes some time before it appears because it loads the map and animates to the specific location.

does activity have some sort of finished loading event ao i can do the map initialization there?

Thanks

Amit Raz
  • 5,370
  • 8
  • 36
  • 63

2 Answers2

1

This is a good blog post that relates to a trick you can do for load times and in fact it is the exact same trick that the Google Maps application uses on the G1.

user432209
  • 20,007
  • 10
  • 56
  • 75
1

If I understand your question correctly, it's not a matter of events, it's a matter of proper programming.

If your activity takes a long time to initialize, you should do the initialization in a background thread (Android supplies the easy to use AsyncTask). While initializing, you should present some temporary content to the user, like a splash screen, a "Loading..." message with a progress bar, or in your case, maybe the last map location (which you probably already have cached).

Try to make the activity life cycle methods (onCreate, onResume, etc), as short and as fast as possible, to make your activity loading snappier, and keep your UI responsive.

See the Designing For Responsiveness entry on the Developer's Guide

Lior
  • 7,845
  • 2
  • 34
  • 34
  • but loading a map is a UI operation, so the UI thread will still be busy while i do it. I just wanted to do it after the activity has finished loading so it is displayed on screen and then load the map. – Amit Raz Jan 30 '11 at 14:52
  • Loading the map is not a UI operation. Displaying portions of (or the entire) loaded map are UI operations. For example, you can load map tiles from the network (background operation), and each time a tile is loaded, display it on the screen (UI operation) – Lior Feb 06 '11 at 12:47