I have a webapp I am trying to interface with android. It is very easy to get a webview to display the page, however the page uses an on screen keyboard. If only one input was on a page, it would be easy to set
android:focusableInTouchMode="false"
in the webview, however there are a few places where multiple inputs are present, and this disables the ability to select any them (the first one on the page is automatically selected).
Would it work to maybe extend and override a webView to be able to select an input but not open the softKeyboard?
I have also looked at this example, however I don't think that will work with a webview.
EDIT:
To help clarify, i can just override with myWebView.setOnTouchListener(...), and have done so in test, this is great as it does not allow the softKeyboard to show, however it also does not let anything else happen ie. input selection. Ideally there would be a happy medium where everything happens except the softKeyboard appearing. (yes I have tried other methods such as
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
I feel that my question was somewhat vague as I was at my wits end after several hours of looking into this.
My end goal was to be able to display a web page with an on screen keyboard with multiple input fields. The problem was that the android softKeyboard would be shown whenever focus was on an input field.
I tried multiple workarounds, one listed in the question did not work because I could not select any inputs as touch commands were not registered.
I tried overriding onTouch, however the keyboard is shown after an 'up' touch and so it was impossible to have default behavior and still intercept and disable the keyboard.
The solution that worked for my problem was to extend the WebView class, and then override 'onCreateInputConnection'. This is where android interprets the 'type' of the html input field. The problem is that html does not have a 'null' type for this, so android will always display some sort of keyboard based on the input type. Android does however have a null input type which tells the keyboard there is no need for input here.
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
BaseInputConnection fic = new BaseInputConnection(this, true);
outAttrs.actionLabel = null;
outAttrs.inputType = InputType.TYPE_NULL;
return fic;
}
This overriden method is all that was needed for my webview to completely disable inputs on all of my text fields.
NOTE: This does also disable attached hardware keyboard input...not a problem in my case, however I would be interested in learning about a work around there.