Yes when the process is killed, everything goes away including your static
variable.  When it is restarted only the activities that need to be
immediately shown are created as they are  needed.  So initially only your
top application will be created.  If you want to clear the stack at that
point, when you go through the list, you will only see that one and finish
it.  A little time later, the one below it will be started and add itself to
the list...  you could check at that point if you are in a "finishing all
activities" state, but would have to carefully manage that.
Ultimately I don't know you exact code, but you can follow the steps I
provided to emulate this common scenario and see how your code works.

On Fri, Sep 18, 2009 at 9:08 AM, sdphil <phil.pellouch...@gmail.com> wrote:

>
> okay.  so, if the process is killed, then the static variable would
> have been killed as well, right?  when the process is restarted, the
> static variable holding the activites will be empty - and as new
> activites get created, they will be added to this list.  in my
> activity's onCreate() method (base class), I add the activity to the
> static list and in the onDestroy() method (base class), I remove the
> activity from the list.
>
> So unless the system kills activites (and not tasks) without my
> knowledge then I'm not sure I see the hole...
>
> Dianne Hackborn wrote:
> > It is not contrived at all, that is the typical behavior when your app is
> in
> > the background and more memory is needed elsewhere.  On a G1 class device
> > where memory is tight, this happens all the time.
> >
> > When the process is killed, your activity state remains in the system,
> and
> > when the user returns to it they activities are re-created as needed so
> that
> > it appears like it had continued running.
> >
> > On Thu, Sep 17, 2009 at 6:41 PM, sdphil <phil.pellouch...@gmail.com>
> wrote:
> >
> > >
> > > that situation seems a bit contrived.  if the process is killed, then
> > > when it gets restarted, doesn't it start the activity from whatever I
> > > have set in my android manifest file?  does it remember what the top
> > > most activity was when the process was killed?
> > >
> > > tia.
> > >
> > > On Sep 17, 6:07 pm, Dianne Hackborn <hack...@android.com> wrote:
> > > > This will probably break if your process gets killed while in the
> > > > background.  For example, run your app so it has some activities,
> press
> > > > home, use adb shell's "ps" to find your process and "kill" to kill
> it,
> > > then
> > > > select it again from home.  You process will be restarted, with the
> > > top-most
> > > > activity started.  None of the others will be running at this point.
> > > >
> > > >
> > > >
> > > > On Thu, Sep 17, 2009 at 5:55 PM, sdphil <phil.pellouch...@gmail.com>
> > > wrote:
> > > >
> > > > > okay, what I wound up doing was to create a base class that all my
> > > > > activities derive from.  then I keep track of the activities in a
> > > > > static variable.  when a derived activity class calls "finishAll()"
> it
> > > > > iterates through the activites it knows about and calls "finish()"
> on
> > > > > them (except if it equals "this").
> > > >
> > > > > Then the client calls "startActivity()" and then calls "finish()"
> > > >
> > > > > On Sep 17, 12:25 pm, Dianne Hackborn <hack...@android.com> wrote:
> > > > > > You can't directly replace the root.  The only way I can think
> > > off-hand
> > > > > to
> > > > > > do this is to use CLEAR_TOP when starting the same activity
> component
> > > as
> > > > > > your current root to send an intent down to that root (and finish
> all
> > > of
> > > > > the
> > > > > > activities in-between, and then handle onNewIntent() there to see
> > > this
> > > > > > intent and start the new desired activity and finish itself.
> > > >
> > > > > > On Thu, Sep 17, 2009 at 11:27 AM, sdphil <
> phil.pellouch...@gmail.com
> > > >
> > > > > wrote:
> > > >
> > > > > > > hi, i want to clear the activity stack and replace it with a
> new
> > > > > > > activity as the root activity, even if that activity exists
> > > somewhere
> > > > > > > on the stack (or not).
> > > >
> > > > > > > i see --   FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_NEW_TASK,
> but
> > > > > > > it's not obvious to me how to use those in conjunction to
> achieve
> > > what
> > > > > > > I want.
> > > >
> > > > > > > it's like i want to completely restart the task with some
> activity
> > > > > > > that i specify as the new root.
> > > >
> > > > > > > tia.
> > > >
> > > > > > --
> > > > > > Dianne Hackborn
> > > > > > Android framework engineer
> > > > > > hack...@android.com
> > > >
> > > > > > Note: please don't send private questions to me, as I don't have
> time
> > > to
> > > > > > provide private support, and so won't reply to such e-mails.  All
> > > such
> > > > > > questions should be posted on public forums, where I and others
> can
> > > see
> > > > > and
> > > > > > answer them.
> > > >
> > > > --
> > > > Dianne Hackborn
> > > > Android framework engineer
> > > > hack...@android.com
> > > >
> > > > Note: please don't send private questions to me, as I don't have time
> to
> > > > provide private support, and so won't reply to such e-mails.  All
> such
> > > > questions should be posted on public forums, where I and others can
> see
> > > and
> > > > answer them.
> > > >
> > >
> >
> >
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com
> >
> > Note: please don't send private questions to me, as I don't have time to
> > provide private support, and so won't reply to such e-mails.  All such
> > questions should be posted on public forums, where I and others can see
> and
> > answer them.
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

Reply via email to