title: Getting values from textbox - Android WebView and JavascriptInterface issue
body: <p>I'm trying to get simple values from two text boxes from my website on click of a button present there.</p>
  
  <p>I followed this - <a href="https://developer.android.com/guide/webapps/webview.html#BindingJavaScript" rel="nofollow noreferrer">https://developer.android.com/guide/webapps/webview.html#BindingJavaScript</a></p>
  
  <p>to basically bind my client-side Android code to my JavaScript function on the website. </p>
  
  <p>This is my Android code -</p>
  
  <pre><code>package course.org.webviewtesting;
  
  import android.app.Activity;
  import android.content.Context;
  import android.os.Bundle;
  import android.view.View;
  import android.view.Window;
  import android.webkit.CookieManager;
  import android.webkit.CookieSyncManager;
  import android.webkit.JavascriptInterface;
  import android.webkit.WebChromeClient;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  import android.widget.ImageView;
  import android.widget.Toast;
  
  /**
   * Created by User on 12/29/2016.
   */
  
  public class WebViewTest extends Activity {
  
  WebView mWebView;
  ImageView logo;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
  
      final Activity mActivity = this;
  
      CookieSyncManager.createInstance(mActivity);
      CookieSyncManager.createInstance(getApplicationContext());
      CookieSyncManager.getInstance().sync();
      CookieManager.getInstance().setAcceptCookie(true);
  
      this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_main);
      logo = (ImageView) findViewById(R.id.logo);
  
      logo.setVisibility(View.VISIBLE); //logo as a loading screen
      // Makes Progress bar Visible
      getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
  
  
  
      mWebView = (WebView) findViewById(R.id.webview);
      mWebView.addJavascriptInterface(new WebAppInterface(this), "android");
      mWebView.getSettings().setJavaScriptEnabled(true);
      mWebView.loadUrl("myURLhere");
      mWebView.setWebChromeClient(new WebChromeClient() {
  
  
          public void onProgressChanged(WebView view, int progress) {
              //Make the bar disappear after URL is loaded, and changes string to Loading...
              mActivity.setTitle("Loading...");
              mActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
  
              if (progress == 100) {
                  mActivity.setTitle(R.string.app_name);
                  logo.setVisibility(View.GONE);
              }
          }
  
  
      });
  
      mWebView.setWebViewClient(new WebViewClient() {
          @Override
          public void onPageFinished(WebView view, String url) {
          System.out.println(" url is " + url);
  
          }
      });
  
  }
  
  // this is from the Android Docs
  public class WebAppInterface {
      Context mContext;
  
      /** Instantiate the interface and set the context */
      WebAppInterface(Context c) {
          mContext = c;
      }
  
      /** Show a toast from the web page */
      @JavascriptInterface
      public void showFields(String email, String name) {
          Toast.makeText(mContext, email+" "+name , Toast.LENGTH_SHORT).show();
          System.out.println("Email " + email + "Name - "+name);
      }
  }
  
  }
  </code></pre>
  
  <p>My HTML is as follows : </p>
  
  <pre><code>&lt;input type="email" id="loginEmail" name="loginEmail" ng-model="loginEmail" ng-required="true" /&gt;
  
  &lt;input type="name" id="name" name="name" ng-model="name" ng-required="true" /&gt;
  
  &lt;button type="submit" class="btn btn-large" ng-click="showValues();" onClick="showValuesAndroid()"&gt;Check Values&lt;/button&gt;
  </code></pre>
  
  <p>And the corresponding JavaScript :</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function showValuesAndroid() {
  var a = document.getElementById("loginEmail").value;
  var b = document.getElementById("name").value;
  Android.showFields(a,b);
  };
      &lt;/script&gt;
  </code></pre>
  
  <p>My function gets the values in variables a and b, but I just can't seem to get the toast message on my WebView on click of the 'Check Values' button.
  Also - a System.out.println doesn't seem to be showing any values either.</p>
  
  <p>Been stuck at this since almost 2 hours, what am I missing out/ doing wrong ??</p>