1

I am working on a project where i have to set value in html form field from my java method . In this app when form load i have to fill text field value on user speech.SO what i can do this using JavaScriptInterface in android. Thanks

1
  • yes you can use javascriptinterface Commented Feb 17, 2014 at 10:43

1 Answer 1

4

MainActivity.java

webView.loadUrl("Your URL");

        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                webView.loadUrl("javascript:setTextField("+value+")");
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;

            }
        });

HtmlFile.html

<script>

        function setTextField(value){
        document.getElementById("texta").value = value;
        }

        </script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.