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()");
}
7
  • 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? Commented Mar 15, 2013 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); Commented Mar 15, 2013 at 11:58
  • Then I do not understand which code you tried from the link you gave. There they do not use the webview. Commented Mar 15, 2013 at 12:56
  • @greenapps i tried this code - Jsoup.connect("http://****/html_form_action.php").data("user",yourTextString).post(); Commented Mar 15, 2013 at 13:34
  • 2
    You should fill the values after the page has been loaded. See <stackoverflow.com/questions/10187908/…> Commented Mar 15, 2013 at 14:30

0

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.