I'm building an app that requires a user to have logged in and obtained a user id. This id is a member variable of my extended Application class.
I'd like the application to recognize when/if this variable gets wiped out and, if so, throw up my log in screen and destroy the Activity stack behind it.
Here's what I think I'm going to do:
Extend Activity and ListActivity (currently the only two types of Activities I am using). In the onResume() handler, check to see if the user id is set. If not, throw up the log in screen and destroy the rest of the Activity stack behind it. All of my Activities will derive from these new extended Activities.
My issue here is that I don't know how to destroy the Activity stack behind a particular Activity. Any ideas?
One idea is to have a broadcast receive listening for a particular message that tells Activities to kill themselves, but I'm hoping Android already has something in place for a situation like this.
Update:
Also, is there a way to clear the entire Activity stack? I'd like to override the onBackPressed() handler on an Activity and have the Activity stack blown out so the user gets taken back to the Android home screen.