This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finish any previous activity in stack from current activity?

 
Pritam Shah
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to finish any previous activity in application stack (at any level , I mean not immediate parent) , from current activity like on some particular event I want to invalidate this previous activity? Any help ? Thanks.
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think you can call finish() without storing a reference of the activity. You can manipulate the activity stack though using appropriate Intent flags(see ACTIVITY_CLEAR_TOP); see if that can help.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would be rude. In fact, it's the kind of thing a virus would do. And on top of that, I believe the Dalvik memory model effectively partitions Activities as though each one ran in its own provate VM, so direct access into the internals of an Activity are made impossible.

The proper way if you want an activity to be cancellable is to provide a notification to that activity so it can decide whether it should shoutdown and how to clean up.
 
Pritam Shah
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:The proper way if you want an activity to be cancellable is to provide a notification to that activity so it can decide whether it should shoutdown and how to clean up.

I think but not sure ( as i am very new to Android) , this is the right way. So I am going with making an intent which carries a message for finishing the activity and registering the target activity with this additional intent which on listening this , kills itself. Any other suggestions welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic