In an application, when you wait for users input you must use EditText wigdets. When users end their inputs and click OK button, you would like close the Android software keyboard. It’s better than asking to users to close software keyboard themselves.

Use that snippet code :

EditText myEditText = (EditText) findViewById(;
InputMethodManager imm = (InputMethodManager)
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);


In other hand, you can want to hide all the time the software keyboard for some reasons (good or bad). To achieve that, there are 2 solutions :

1. First is linked to Android Manifest. Use the following attribute for your activity targeted :


2. Second is achieved programmatically :