views:

35

answers:

1

How do I close a whole hierarchy of activities and show a new activity not present in the current task?

Context

Consider a FTP browser that resumes the previous session on launch. Each folder is displayed in its own activity. When I click on a folder, a new activity is started for the folder. If I press the back button, the app returns to the previous activity, which corresponds to the the parent folder.

I can logoff from the menu at any time. Logging off should bring me to the login activity (not present the current task when the app has resumed the session), and close all the other activities. How can I do this?

From what I've read, if the activity were in the current task I could use FLAG_ACTIVITY_CLEAR_TOP in the intent, but this is not my case.

A: 
bhups
Thanks bhups! This is what we're doing right now (our constant is called RESULT_KILLER_VIRUS :P ), but it seemed awfully complicated and error-prone. Hope there's a better solution.
hgpc
How about using ActivityGroup in conjunction with LocalActivityManager? You can have LoginActivity and FolderActivityGroup. Use LocalActivityManager to start FolderActivity's and when user logs off then you can destroy all the activities in the FolderActivityGroup by calling LocalActivtyManager.removeAllActivities().
bhups