title: How to call JavaScript with Android 4.4 Webview?
body: <p>I wanted to modify one input value in the html after loading the webpage. I prepared to do this by calling javascript function with the WebView. It worked well if I set the <code>android:targetSdkVersion</code> to 18. But once I set it to 19, it shows the value of the second url, even it's just the javascript calls. Here's test code:</p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  
  public class WebActivity extends Activity {
      private WebView mWebView;
      private String mJSCall;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          setContentView(R.layout.activity_webview);
  
          mWebView = (WebView)findViewById(R.id.webview);
          mWebView.getSettings().setJavaScriptEnabled(true);
  
          mWebView.setWebViewClient(new WebViewClient() {
              @Override
              public void onPageFinished(WebView view, String url) {
                  if (mJSCall != null) {
                      view.loadUrl(mJSCall);
                      mJSCall = null;
                  }
  
                  super.onPageFinished(view, url);
              }
  
              @Override
              public boolean shouldOverrideUrlLoading(WebView view, String url) {
                  // TODO Auto-generated method stub
                  view.loadUrl(url);
  
                  return super.shouldOverrideUrlLoading(view, url);
              }
  
          });
  
          mWebView.loadUrl("http://wap.soso.com/?g_f=2405");
          String keyword = "My Keyword";
          mJSCall = "javascript:document.getElementById('keyword').value='"+keyword+"'";
  
          super.onCreate(savedInstanceState);
      }
  }
  </code></pre>
  
  <p>Could you tell me why it failed to call javascript function when <code>targetSdkVersion=19</code>? It seems that when the <code>onPageFinished</code> method is called the first url already refreshed sometimes, maybe that's why I could not modify the value in the html at that time.</p>
  
  <p>So is there any right time to call javascript except the <code>onPageFinished</code>? I have struggled for the last day to find a reasonable solution. If anyone can help, please do. Thank you!</p>