3

I have a problem with inserting saved data from Android app into html input. Site is loaded into WebView component, so i have access to my site in my app, but i still can't insert saved data (from previous activities) into html text input... I have found some code - webview.loadUrl("javascript:document.getElementById('pass_id').value = 'y2Yb2q2ckM'"); and tried use code from this link - https://stackoverflow.com/a/12450427/1196540 but those codes does not worked for me... Can anyone give advice or help me with my problem?

UPD and here is my web-form:

<form method="post" action="">
<input name="pass" id="pass_id" type="password" autocomplete="off" value="" class="keyboardInput" onkeyup="$('#warn2').show();"/>

UPD 2

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_browser_screen);

    Intent intent = getIntent();
    CLIENT_ID = intent.getExtras().getString("CLIENT_ID");
    lang = intent.getExtras().getString("LANGUAGE");
    CLIENT_PWD = intent.getExtras().getString("PASSWORD");

    if (lang.equals("English"))
        url = link.getEng();
    else if (lang.equals("Russian"))
        url = link.getRussian();
    else if (lang.equals("Dutch(German)"))
        url = link.getDeutch();
    else if (lang.equals("French"))
        url = link.getFrance();
    else if (lang.equals("Italian"))
        url = link.getItalian();
    else if (lang.equals("Spanish"))
        url = link.getSpanish();

    //go to the website
    WebView webview = new WebView(this);
    setContentView(webview);
    WebSettings webSettings = webview.getSettings();
    webSettings.setJavaScriptEnabled(true);

    webview.setWebViewClient(new WebViewClient());

    data = "client_id=" + CLIENT_ID;
    webview.postUrl(url, EncodingUtils.getBytes(data, "base64"));

    //insert pass
    //webview.loadUrl("javascript:document.getElementById('pass_id').value = 'y2Yb2q2ckM'");
    webview.loadUrl("javascript:document.getElementById('pass_id').focus()");
}
Community
  • 1
  • 1
vladimir
  • 695
  • 3
  • 15
  • 34
  • The other poster had the same problem but the solutions he got were not what he asked for. Instead of displaying the data in the inputs of the webpage in a webview they posted the values to a site. Now what do you want? Display the data? Have you enabled javascript for the webview? – greenapps Mar 15 '13 at 10:17
  • @greenapps yes, i want to insert data into input because it is input for user password, and yes i was enabled javascript with this line - `webSettings.setJavaScriptEnabled(true);` – vladimir Mar 15 '13 at 11:58
  • Then I do not understand which code you tried from the link you gave. There they do not use the webview. – greenapps Mar 15 '13 at 12:56
  • @greenapps i tried this code - `Jsoup.connect("http://****/html_form_action.php").data("user",yourTextString).post();` – vladimir Mar 15 '13 at 13:34
  • But that code is not displaying the form with the data in your webview. So what does it have to do with where you try to use javascript to put the data in the inputs? Your javascript should work but only after the page is completely loaded. So how have you implemented that? – greenapps Mar 15 '13 at 14:16
  • @greenapps I have updated my question with java implementation – vladimir Mar 15 '13 at 14:25
  • 2
    You should fill the values after the page has been loaded. See – greenapps Mar 15 '13 at 14:30

0 Answers0