i have an application that has "login" and "logoff" actions. after the user logs in, there could ne an arbitrary number of activities left on the stack at the point when they log off.
when the user logs off, i want all application state to be reset. i clear my disk caches and preferences, but there's still state left in running (paused) activities. in fact, when the user logs in again, i find that the old activities from the previous login session are still there with their old state (i understand why this is of course). how can i cause the entire app to reset / close / restart?
i've seen a few posts about using startActivityForResult()
, onActivityResult()
to bubble up a "logoff" result code causing each activity to close itself in turn. this looks painful and i'm hoping there's a better way.
EDIT: i've tried starting the "log in" activity with various flags to no avail,
loginIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);