I want to implement the back button functionality in my application. In application whenever I'm clicking on back button in middle my control is going to login page directly, so can someone tell me where to override onKeyDown()
or onBackPressed()
methods?
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
Log.e("back key pressed","Back key pressed");
return true;
}
return super.onKeyDown(keyCode, event);
}
because I'm writing this inside onCreate and outside onCreate also, but it's not working ......