Fill in web form from an app and submit

Viewed 5349

I have a webpage with a simple form with 3 input fields, Name, Email and Course and a submit button. Nothing fancy.

Upon developing an android app, I would like to know how I could fill in that web form from within my android app without using a webview to actually load the webpage.

6 Answers

This is better

    WebView web = (WebView)findViewById(R.id.web1);
    web.getSettings().setJavaScriptEnabled(true);
    web.getSettings().setDomStorageEnabled(true);
    web.loadUrl("url_address");
    web.setWebViewClient(new WebViewClient(){
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            web.loadUrl("javascript:document.getElementById('username').value = 'alireza'; null");
            web.loadUrl("javascript:document.getElementById('password').value = '12345678'; null");
            web.loadUrl("javascript:document.getElementById('login_button').click(); null");
        }
    });
Related