You have several ways to solve this
-In your AndroidManifest.xml : You can hide the keyboard when you enter the activity using the windowSoftInputMode
property that you can find in the documentation . This configuration hides the virtual keyboard when the user opens a new Activity. The keyboard will be displayed only when the user clicks on the EditText.
Example:
<activity android:name="com.tu.paquete.Activity"
android:windowSoftInputMode="stateHidden" />
-With the InputMethodManager : if you want to make sure that the input method is visible / hidden in any part of the life cycle of your activity you can use InputMethodManager
to display it, as indicated by < a href="https://developer.android.com/training/keyboard-input/visibility.html#ShowOnDemand"> documentation .
Example:
/**
* Hides the soft keyboard
*/
public void hideSoftKeyboard() {
if(getCurrentFocus()!=null) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
}
/**
* Shows the soft keyboard
*/
public void showSoftKeyboard(View view) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
view.requestFocus();
inputMethodManager.showSoftInput(view, 0);
}
Code extracted from the following response from SOEn and the documentation