Calling Javascript method from within webview in Android
<p>I am trying to call a javascript method defined in a html page from within webview. Function is not being called, and I don't see any errors in the log.</p>

<p>This is html file.</p>

<p>
        
        
            
            
            </p>

<pre><code>    &lt;/head&gt;
    &lt;body&gt;
    &lt;script type="text/javascript"&gt;
        function callJS(){
            $.ajax({url:"http://10.0.2.2:5010"});
        }
    &lt;/script&gt;
    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<p>And this is the Java code in a Activity in android</p>

<pre><code>    WebView webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl("file:///android_asset/temp.html");
    webView.loadUrl("javascript:callJS()");
</code></pre>

<p>Not sure how to debug this. When I add a <code>onload=callJS()</code> in body tag in html, I see the remote call being made. So, it looks like my HTML is fine,and it is being loaded into webview. However, webview is not able to call javascript method directly.</p>