title: Website Login by using WebView Javascript Android
body: <p>On Button click:</p>
  
  <pre><code>    public void login(View v) {
  
          InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
          imm.hideSoftInputFromWindow(rlayout.getWindowToken(), 0);
  
  
          loginWebView.loadUrl("https://example.de");
          loginWebView.setVisibility(View.INVISIBLE);
          loginWebView.setWebViewClient(new WebViewClient() {
  
              public void onPageFinished(WebView view, String url) {
                  loginWebView.loadUrl("javascript: {" +
                          "document.getElementById('login_act').value = '" + "USNAME" + "';" +
                          "document.getElementById('login_pwd').value = '" + "PWD" + "';" +
                          "document.getElementById('submit').click();" +
                          "};");
              }
  
              public void onPageFinished2(WebView view, String url) {
                  loginWebView.loadUrl(url);
              }
          });
  
          loginWebView.clearCache(true);
          loginWebView.clearHistory();
  
  
      WebView view = (WebView) this.findViewById(R.id.mainwebView);
  
      String url = "https://example.de";
      view.loadUrl(url);
  
  
  }
  </code></pre>
  
  <p>On Button click:
  1- 1. WebView Login
  2- 2. WebView show Page
  3- Ready</p>
  
  <p>At my first try all worked. No Error, no problems. The only thing was, that the WebView loaded with the page, where i was not logged in.</p>
  
  <p>How can i log in and what went wrong ?</p>