Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling autosuggestion on WebView?

I have some HTML text inputs into a WebView, and I need to disable the autosuggetions on these inputs from Android, not from HTML (autocomplete=off).

How can I do this?

like image 793
Buda Florin Avatar asked Sep 13 '11 15:09

Buda Florin


4 Answers

This problem vexed me for quite a while but the solution is very simple:

webview.getSettings().setSaveFormData(false);

I wrote about it here:

http://roysutton.com/2012/02/21/preventing-auto-fill-in-android-webview/

like image 188
Pre101 Avatar answered Nov 14 '22 08:11

Pre101


The suggested above answers didn't help me. So I found next solution: I just created a simple wrapper for WebView and used it.

public class NoSuggestionsWebView extends WebView {
    public NoSuggestionsWebView(Context context) {
        super(context);
    }

    public NoSuggestionsWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NoSuggestionsWebView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
        InputConnection ic = super.onCreateInputConnection(outAttrs);

        outAttrs.inputType &= ~EditorInfo.TYPE_MASK_VARIATION; /* clear VARIATION type to be able to set new value */
        outAttrs.inputType |= InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD; /* WEB_PASSWORD type will prevent form suggestions */

        return ic;
    }
}
like image 29
lpsun Avatar answered Nov 14 '22 10:11

lpsun


In addition to setSaveFormData setting as False, this also helped me

WebView.getSettings().setSavePassword(false);
WebView.clearFormData();
like image 5
Kamal Avatar answered Nov 14 '22 10:11

Kamal


None of the above helped so after extensive search i found this which works perfect on webview as well as normal websites. Text area can be replaced by Input text fields too :)

<textarea class="form-control" id="comments" autocomplete="off" autocorrect="off"  spellcheck="false"></textarea>
like image 2
Uma Shankar Goel Avatar answered Nov 14 '22 10:11

Uma Shankar Goel