How to remove the keyboard after the operation is completed?

I have an action that users enter inside and then click OK. Upon completion, the action closes and returns to the old action, but the soft keyboard still remains on the screen! I tried android:windowSoftInputMode="stateHidden" and

 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

But it does nothing.

+8
source share
1 answer

In onpause of your activity you should do the following

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

Where et is an instance of your EditText.

+22
source

All Articles