In my activity, I have a editText field. When the user taps on it, the editText gains the focus and the keyboard appears. Now, when the user presses the hardware back button on the phone, the keyboard disappears but the cursor remains in the Edittext, i. e., it still has the focus. Is it possible to make the EditText lose focus when back button is pressed? I tried using the following code but it didn't work:
@Override
public void onBackPressed() {
vibrator.vibrate(Constants.DEFAULT_VIBRATE_TIME);
myEditText.clearFocus();
super.onBackPressed();
}