views:

62

answers:

1

Hi,

I've got a simple application with 3 activities: -the first contains a search box which calls a web service and show the results (restaurants) below in a listview -when a restaurant is clicked another activity is started showing the description of the restaurant and a button "show map" -when the button "show map" is clicked, guess what, the map is shown in a third activity.

All the data is loaded in the first activity by a web service (restaurant descriptions and coordinates), and data required by each activity is passed in a bundle using "intent.putExtra".

Now everything seems to run smoothly when clicking on the back button (eg. clicking on the back button from the map resumes the "restaurant description" activity with all data set properly), while I haven't done anything about the lifecycle yet.

Why? Are all variables saved automatically? Should I use onSaveInstanceState() and onRestoreInstanceState() anyway?

Thanks

Jul

A: 

When new activity B starts on top of another activity A, acitivty A will not be destroyed by default, it becomes stopped and after that you just resume it. If system needs resources, it can destroy stopped activity. There is a nice graph here that really explains lifecycles of components.

Rabas
Is the Bundle saved using onSaveInstanceState recovered on onCreate if the activity has been destroyed?
jul
Yes, it is passed to onCreate and to onRestoreInstanceState.
Rabas