How to dismiss the keypad in Android

If you want to dismiss the keypad manually through code, you can do that with the following methods

Method 1



Call these lines on which EditText you want to dismiss the keypad.

EditText txtEmail = (EditText) findViewById(R.id.inputEmail);

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(txtEmail.getWindowToken(), 0);