title: Calling Intent in a javascript Webview
body: <p>I'm using this code to call an Android Activity using HTML button. But it is not working for me. I just want to call my Android Activity "echos.class" when I click the Button from my html page.</p>
  
  <p>my JavaScriptInterface class</p>
  
  <pre><code>public class JavaScriptInterface {
      Context mContext;
  
      /** Instantiate the interface and set the context */
      JavaScriptInterface(Context c) {
          mContext = c;
      }
  
  
      /** Show a toast from the web page */
      public void showToast(String toast) {
          Intent mainIntent = new Intent(mContext, echos.class); 
          JavaScriptInterface.this.startActivity(mainIntent); 
  
  
      }
  
  
      private void startActivity(Intent mainIntent) {
          // TODO Auto-generated method stub
  
      }
  }
  </code></pre>
  
  <p>my webview class</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          WebView myWebView = (WebView) findViewById(R.id.web1);
          WebSettings webSettings = myWebView.getSettings();
          webSettings.setJavaScriptEnabled(true);
          myWebView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
          myWebView.loadUrl("file:///android_asset/www/index.html");
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <p>my html page</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;input type="button" value="Say hello" onClick="showAndroidToast('Hello Android!')" /&gt;
  
      &lt;script type="text/javascript"&gt;
      function showAndroidToast(toast) {
          Android.showToast(toast);
      }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>