A
A
Andrey2017-02-24 15:28:55
Android
Andrey, 2017-02-24 15:28:55

How to inject data into webview?

There is an application running under android 4.4, which has a webview. This webview opens a page with a form with many fields (tag ). The question is whether it is possible to automatically fill in some fields on this form after loading the page, if so, how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-02-24
@poslannikD

Through the butt:

public class WebClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }

    @Override
    public void onPageFinished(WebView view, String url) 
    {       
        view.loadUrl("javascript:document.forms[0].q.value='qwerty'");
    }
}

WebView webview = new WebView();
webview.setWebViewClient(new WebClient());
webView.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("toster.ru");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question