views:

292

answers:

1

In my android app I have a Tabhost with a ListView as one of the tabs. By clicking on an item in the ListView (an address) I start an Intent to Google Maps for directions and the choice dialog pops up for google maps, web browser etc. Problem is if I press the hard back button then the launch dialog goes away but also the ListView is cleared. Any idea why?

+1  A: 

The caller activity is being "paused" and when resumed onCreate is called to let you "resume". You can save persistent data by overriding onSaveInstanceState and passing the data through the bundle by setting extras. Then check for these extras in the bundle passed to onCreate and perform any necessary actions needed to functionally resume.

For complex objects, you can serialize them (implement Serializable if need be) and then store them as extras in the bundle during onSaveInstanceState.

Berdon Magnus
A paused activity is only freed if the device is in pretty dire need of memory. And even then, because it would have a higher priority than other activities because it is still partially visible, fully background apps should go first. It's probably only going through the onResume()
jqpubliq
Only onResume is called. In onResume i was calling processResults(results) but in processResults(results) I was calling this.results.clear() when this.results was the list that was passed in. Just had to do a processResults(new ArrayList(results)) in onResume.
BrennaSoft