title: I cannot call an android function from javascript
body: <p>I just started make a kind of Android hybrid app, an application with WebView. As a first step, I tried to call a function of Android code from JavaScript. But, the app keeps crashing while I am at it.</p>
  
  <p>All I did was setting up WebView, adding a class that is used from JavaScript code, then calling the function from JavasScript.</p>
  
  <p>Thanks in advance.</p>
  
  <p>The android codes are following:</p>
  
  <pre><code>public class Grand_ride_androidActivity extends Activity {
      WebView mWebView;
  ...
     public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          mWebView = (WebView) findViewById(R.id.webview);
          mWebView.getSettings().setJavaScriptEnabled(true);
  
  
          mWebView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
          mWebView.loadUrl(Config.url);
      }
  }
  
  public class JavaScriptInterface {
      Context mContext;
  
      JavaScriptInterface(Context c) {
          mContext = c;
      }
  
      public void ensureTracking(Integer rideId) {
          //do nothing
      }
  }
  </code></pre>
  
  <p>And the HTML is following:</p>
  
  <pre><code>...
  &lt;body&gt;
  
  &lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
          Android.ensureTracking(97);
  //]]&gt;
  &lt;/script&gt;&lt;div&gt;
          &lt;p&gt;You have checked in at 03:44PM&lt;/p&gt;
          &lt;a href="/rides/97/check_out"&gt;Check out&lt;/a&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>