title: Javascript calling Android methods in WebView
body: <p>I have some javascript running in WebView. In this Javascript code there a function which returns a boolean. I want to check the return value from this function and depends on it hide or not a view in my android code. I tried for one day and it does not work. Do someone knows where is my error? This is my code:</p>
  
  <pre><code>public class MyActivity extends Activity {
      private static final String JS_INTERFACE  = "Android";
      ....
  
      webView.getSettings().setJavaScriptEnabled(true);
      webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
      webView.loadUrl(getUrl(this.getResources().getString(R.string.host)));
      webView.addJavascriptInterface(new WebViewJavaScriptInterface(this), JS_INTERFACE);
      webView.setWebViewClient(new WebViewClient(progressBar, this, tvError));
      webView.setWebChromeClient(new WebChromeClient(progressBar));
  
      webView.loadUrl("javascript:window.Android.showAdBanner(showSdkAd())");
  }
  
  public class WebViewJavaScriptInterface
  {
      ....
      @JavascriptInterface
      public void showAdBanner(String jsResult) {
          if (jsResult == "true") {
              ((Activity) context).findViewById(R.id.adView).setVisibility(View.GONE);
          } else {
              ((Activity) context).findViewById(R.id.adView).setVisibility(View.GONE);
          }
     }
  }
  </code></pre>