[android-developers] Re: how to clear activity stack in task

2010-01-06 Thread jwei512
Are you looking for a practical answer? Or was this more of a
theoretical thought experiment type of question?

If you want the practical answer, then I guess the simple thing to do
would be to kill Activity A in it's onActivityResult method (which
should be overridden since you are calling startActivityForResult on
Activity B). In other words, before B kills itself, do something like
setResult(RESULT_OK) and then kill B. Once this happens, it will
return to Activity A's onActivityResult method, and in there you can
have something like

if(resultCode == RESULT_OK) {
  finish();
}

And so at this point, Activity C is what your user should see, and
Activity A/B have been killed off, and so once you kill Activity C
your Activity stack is cleared and you're good to go.

Hope this is what you were looking for.

- jwei

http://thinkandroid.wordpress.com

On Jan 6, 1:12 am, Zhihong GUO gzhh...@gmail.com wrote:
 Hi all,

 I have three activities. Activity A start activity B by the method
 startActivityForResult, and Activity B start activity C by the method
 startActivity. Then, after starting activity C, activity B kill himself by
 finish(). Now the task stack stored two activities: A and C.

 My question is: how can I finish activity A when I finish activity C. or how
 can I clear the whole stack of the task.

 Thanks a lot!

 James
-- 
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

[android-developers] Re: how to clear activity stack in task

2010-01-06 Thread Manoj


I am also facing the same problem in my application in my application
A starts B and B starts C now C is on the screen and i want to close
the complete app in just a single click of button.


Manoj Chauhan
-- 
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

Re: 回复: [android-developers] Re: how to clear activity stack in task

2010-01-06 Thread Matt Kanninen
Hard to do without changing code.  I always end having to implement
logout(), so all my activities extend a custom base activity, and in
that base activity in onCreate I always end up checking for a global
static:

if(!isLoggedIn){
  finish();
  return;
}


On Jan 6, 4:43 am, Zhihong GUO gzhh...@gmail.com wrote:
 thanks for the quick answer. but is there any other solutions? i mean do not
 change the code of activity a and b, just clear the task stack.
-- 
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