I have a couple of activities in my project which will be called when different buttons will be pressed.
What I'm looking for is a way to close and exit the application completely whenever and wherever the user presses the BACK or Home Button!how should I handle this?
here is my code,but here I navigate this page to the Login Class which is my start up activity!
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_HOME)
{
Intent intent = new Intent(this, Login.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
}
else if(keyCode==KeyEvent.KEYCODE_BACK)
{
Intent intent = new Intent(this, Login.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
}
Toast.LENGTH_LONG).show();
return false;
}
Any Suggestions will be appreciated.