I have a webView
inside an Activity's layout. If back button is pressed, I want that view to disappear and other views to become visible, to I did the following:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && web.getVisibility()==View.VISIBLE) {
restoreInitalState(); // set Visibility of Views
APP_CONSTANTS.LOGIN_OP_CANCELLED(getApplicationContext()); // inform the user that the current operation was cancelled
}
return super.onKeyDown(keyCode, event);
}
it works BUT it finishes the Activity immediately after calling my methods, like if the back button was pressed 2 times. I need to keep the current Activity and just call my methods mentioned above. Any suggestions?