aspose file tools*
The moose likes Android and the fly likes Finish any previous activity in stack from current activity? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Finish any previous activity in stack from current activity?" Watch "Finish any previous activity in stack from current activity?" New topic
Author

Finish any previous activity in stack from current activity?

Pritam Shah
Greenhorn

Joined: Jul 13, 2009
Posts: 25
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

Joined: Oct 12, 2008
Posts: 1369
    
    1

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.


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Pritam Shah
Greenhorn

Joined: Jul 13, 2009
Posts: 25
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Finish any previous activity in stack from current activity?