title: Android Calling JavaScript functions in WebView
body: <p>I am trying to call some javascript functions sitting in an html page running inside an android webview.  Pretty simple what the code tries to do below - from the android app, call a javascript function with a test message, which inturn calls a java function back in the android app that displays test message via toast.</p>
  <p>The javascript function looks like:</p>
  <pre><code>function testEcho(message){
       window.JSInterface.doEchoTest(message);
  }
  </code></pre>
  <p>From the WebView, I have tried calling the javascript the following ways with no luck:</p>
  <pre><code>myWebView.loadUrl(&quot;javascript:testEcho(Hello World!)&quot;);
  mWebView.loadUrl(&quot;javascript:(function () { &quot; + &quot;testEcho(Hello World!);&quot; + &quot;})()&quot;);
  </code></pre>
  <p>I did enable javascript on the WebView</p>
  <pre><code>myWebView.getSettings().setJavaScriptEnabled(true);
  // register class containing methods to be exposed to JavaScript
  myWebView.addJavascriptInterface(myJSInterface, &quot;JSInterface&quot;); 
  </code></pre>
  <p>And heres the Java Class</p>
  <pre><code>public class JSInterface{
  
  private WebView mAppView;
  public JSInterface  (WebView appView) {
          this.mAppView = appView;
      }
  
      public void doEchoTest(String echo){
          Toast toast = Toast.makeText(mAppView.getContext(), echo, Toast.LENGTH_SHORT);
          toast.show();
      }
  }
  </code></pre>
  <p>I've spent a lot of time googling around to see what I may be doing wrong.  All examples I have found use this approach.  Does anyone see something wrong here?</p>
  <p><strong>Edit:</strong>  There are several other external javascript files being referenced &amp; used in the html, could they be the issue?</p>