DEV Community

Mayank
Mayank

Posted on

Answer: How to use Android autofill API

A simple solution would be to let webview handle this.

webView.getSettings().setSaveFormData(true);

    webView.getSettings().setJavaScriptEnabled(true)
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(true);
    webView.setWebChromeClient(new WebChromeClient() /*Or yourOwnWebChromeClient*/);
    webView.setWebViewClient(new WebViewClient() /*Or yourOwnWebViewClient*/);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setSaveFormData(true);

    CookieSyncManager.createInstance(this);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    CookieSyncManager.getInstance().startSync();

You may also add JavaScript Interface if needed

    webView.addJavascriptInterface(this, JSInterface);

I used this approach and it saved the…

Top comments (0)