I want it to be impossible for the soft keyboard to pop up due to an action in the my webView. That's because I have a custom "keyboard" consisting of buttons below the webView. However, I don't want to completely disable the keyboard for my application, as I have to use it in different contexts. It just shouldn't show up when the user clicks on an input field inside the webView. I also don't want the keyboard to show and instantaneously hide again.
I currently have this in my AndroidManifest.xml
:
android:windowSoftInputMode="stateAlwaysHidden"
I already tried disabling the focus of the webView, but then I can't enter text with my custom "keyboard" either, as the input field of the webView aren't focused.
I also tried this in onCreate
, but it didn't work (the keyboard still showed up):
View focusedView = this.getCurrentFocus();
if (focusedView == null)
return;
InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (manager == null)
return;
manager.hideSoftInputFromWindow(focusedView.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);