> When switching back and forth between activities, by default, they are not
> destroyed and recreated - unless necessary.

This is irrelevant.  Activities, by default, are destroyed when
clearing the task.

> If you are concerned with maintaining state (like a list view's scroll
> position), you need to review the Activity Lifecycle.

Although it is possible to maintain the state after finishing
activities, that's not what I'm asking about.

The idea is to clear the navigation stack, which is called the Task in
Android, when navigating to certain Activities, without finishing
other Activities.  To keep the Task empty, the Activities are indeed
destroyed by Android.  What I want is to keep the Task empty without
destroying the Activities.  This is so that pressing BACK will exit
the application on any of these "tab" activities, but that switching
between the "tab" activities won't destroy and recreate them.  In a
purely theoretical sense, these "tab" activities would share the same
position 0 in the stack.

The TabActivity uses an ActivityGroup to accomplish this.  What I want
to know is if there is a way to flag either the Activity in the
manifest, or the Intent which starts the Activity, to accomplish
this.

...

After giving this some thought, I think that this is not possible, and
this is my theory on why.  I theorize that Android internally keeps
track of which Activities are open inside of a process with tasks: a
process has a List<Task>.  A Task correspondingly would have a
Stack<Activity>. This is the only data collection which contains
available Activities; otherwise the process would require two data
collections to track: a List<Task> and a List<Activity>. Or, a Task
would have a Stack<Activity> of Activities on the navigation stack and
a List<Activity> of unfinished Activities not on the navigation
stack.

Having two data collections to track, while not impossible, would be
slightly messier.  If it is the case that the only data collection of
Activities a process has is List<Task> and the Task correspondingly
only has a Stack<Activity>, and if the OS cleared the task without
finishing() the Activities, then it would have no reference to the non-
finished Activities, so there would be no way for Android to find an
Activity that is already instantiated and non-finished.  Essentially,
for this to work, a Task would have to have both a navigation stack of
non-finished Activities Stack< Activity > and a list of unfinished
Activities List<Activity> to support this framework.

In any case, even if the above theory is incorrect, I can't find the
equivalent of a CLEAR_NAVIGATION_STACK flag which doesn't finish the
Activities in a Task.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to