Hide soft keyboard after dialog dismiss

android, android-softkeyboard, hide, keyboard, soft-keyboard

Solution

In Manifest xml

android:windowSoftInputMode="stateAlwaysHidden"

It will automatically hide soft keyboard on Dismiss of `Dialog`

Problem

I want to hide soft keyboard after AlertDialog dismiss, but it's still visible. Here is my code: ``` alert = new AlertDialog.Builder(MyActivity.this); imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); alert.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); } }); ```

Original source

Related problems