You are right: calling finish() will only exit the current activity, and not the entire application. however there is a workaround for this:
Every time you start an action, run it using startActivityForResult(...) . When you want to close the entire application, you can do something like this:
setResult(RESULT_CLOSE_ALL); finish();
Then define each onActivityResult(...) activity onActivityResult(...) , so when the action returns with the value RESULT_CLOSE_ALL , it also calls finish() :
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch(resultCode) { case RESULT_CLOSE_ALL: setResult(RESULT_CLOSE_ALL); finish(); } super.onActivityResult(requestCode, resultCode, data); }
This will lead to a cascading effect that closes all actions.
In addition, I support CommonsWare on its assumption: store the password in a variable so that it is destroyed when the application is closed.
mtmurdock Jun 24 '10 at 1:25 2010-06-24 01:25
source share