Switching between two map Activities

327
2
01-13-2012 10:36 AM
BradFrecker
New Contributor
I am developing an application which contains two activities, each of which contains a map view.  Activity 1 creates and uses its map, starts Activity 2 and calls map.recycle() in onPause before Activity 2 begins.  Activity 2 runs, creates and uses its map, and calls map.recycle() in onPause as it finishes.  This all works fine.

The problem comes when Activity 1 resumes.  It goes through the process of adding a map layer and a couple of graphics layers to the MapView object, but the map does not appear on the display.

Can I reuse the MapView object as I am attempting to do, or do I need to destroy it completely and create a new one each time Activity 1 resumes?

If any of this is unclear, let me know and I'll try to clarify.

Thanks,

Brad
0 Kudos
2 Replies
IvanBespalov
Occasional Contributor III
Brad,
yes you can reuse: save instance state and restore it as u need.

To save activity state use onSaveInstanceState().
To restore activity state use onRestoreInstanceState().
0 Kudos
SaurabhGupta
New Contributor II
0 Kudos