0

Please help me how can i invoke a submit action after loading this html.

WebView webView = (WebView) findViewById(R.id.webview);        
String formData = "<!DOCTYPE html>\n" +
            "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" +
            "<head>\n" +
            "<title>SSO OutBound Settings</title>" +
            "</head>\n" +
            "<body>" +
            "<form name='frmMain' id=\"frmMain\" runat='server' method='POST'" +
            "action='" + ---data--- + "'>" +
            "<input type='hidden' name='" + ---data--- + "'" +
            "value='" + ---data--- + "'/>" +
            "<input type='hidden' runat='server' name='" + ---data--- + "' " +
            "value='" + ---data--- + "'/>" +
            "</form>" +
            "</body>\n" +
            "</html>";
webView.loadData(formData, "text/html", "UTF-8");
Iamat8
  • 3,888
  • 9
  • 25
  • 35
Dinesh Kumar
  • 37
  • 1
  • 6

2 Answers2

1

I think you'd need to do this in javascript. So it would have to be enabled for your web view:

webView.getSettings().setJavaScriptEnabled(true);

Submitting the form should be something like:

webView.loadUrl("javascript:document.frmMain.submit()");
wamfous
  • 1,849
  • 1
  • 12
  • 11
0

You may use an http client for that - Android HttpURLConnection, Apache httpclient, Volley etc. The idea is to send http POST with form data to requred resource. See Sending POST data in Android

Community
  • 1
  • 1
Alexey
  • 1,198
  • 1
  • 15
  • 35