views:

49

answers:

2

Well.. the title is pretty descriptive, I have a bunch of tab activities (which I implemented myself, didn't want to use the tabviews with activities inside them), so It's basically 5 activities calling each other every time the user clicks on the tabs displayed as a row of LinearLayouts at the bottom of the screen.

The thing is that the way I do it now, everytime the user jumps from one activity to another, a new activity is created and launched. Of course, I can see I'm wasting resources this way. So what I would like to do is to create every activity only once; and then if the user wants to go back to the previous (or any one that was already created and is probably paused) just check on some kind of list or array to see if the activity can be recovered and only in the case it can't; to lauch a new one.

My question is, how can I check this? should I save the intents? and how to recover the activities afterwards? I'm kind of new with java.

Greetings Nelson R. Perez

A: 

When your activities are paused or stopped, you should save the state of your activity in a Bundle (check the activity lifecicle)

Then, when your activity starts, you'll have access to the Bundle where yo usaved your previous state : it's the parameter of the onCreate & onStart methods.

Moons
+3  A: 

Intent.FLAG_ACTIVITY_REORDER_TO_FRONT

Set this flag in the intent used to create the activity and, if it exists, it should be brought to the front instead of created again.

drawnonward