I have seen and used both of the methods to hide the on screen keyboard while coding Android:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
I have read through the documentation for both and I am still unclear as to how each is different, the same, which is a better method or practice to use, and which one should be used in which situations.
Here is an excerpt from the
Specify an explicit soft input mode to use for the window, as per WindowManager.LayoutParams.softInputMode. Providing anything besides "unspecified" here will override the input mode the window would normally retrieve from its theme.
And here is an excerpt from the
InputMethodManager documentation that seems to say nearly the same thing:
You can also control the preferred soft input state (open, closed, etc) for your window using the same windowSoftInputMode attribute.
More finer-grained control is available through the APIs here to directly interact with the IMF and its IME -- either showing or hiding the input area, letting the user pick an input method, etc.
So what is the difference in these two options to hide the Android soft keyboard, and does one have a benefit over the other? Is one more efficient? What are specific uses for each?