title: Android App: Adding Mailto to Web View for email functionality
body: <pre><code>package com.helloworld;
  
  import android.app.Activity;
  import android.os.Bundle; 
  import android.view.Window;
  import android.webkit.WebChromeClient;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  import android.view.KeyEvent;
  import android.content.Intent;
  import android.net.MailTo;
  import android.content.Context;
  
  
  public class HelloWorld extends Activity
  {
      final Activity activity = this;
  
  
      WebView webview;
      @Override
      public boolean onKeyDown(int keyCode, KeyEvent event) {
      if (webview != null &amp;&amp; (keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; webview.canGoBack()) {
          webview.goBack();
          return true;
      }
      return super.onKeyDown(keyCode, event);
      }
  
      @Override
     public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
          setContentView(R.layout.main);
  
  
          webview = (WebView) findViewById(R.id.webview);
          webview.getSettings().setJavaScriptEnabled(true);
          webview.getSettings().setBuiltInZoomControls(true);
          webview.getSettings().setUseWideViewPort(true);
          webview.loadUrl("http://www.blahblah.org");
  
          webview.setWebChromeClient(new WebChromeClient() {
              public void onProgressChanged(WebView view, int progress)
              {
                  activity.setTitle("Loading...");
                  activity.setProgress(progress * 100);
  
                  if(progress == 100)
                      activity.setTitle(R.string.app_name);
              }
          });
  
          webview.setWebViewClient(new WebViewClient() {
              @Override
              public void onReceivedError(WebView view, int errorCode, String       description, String failingUrl)
              {
              // Handle the error
              }
  
       @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url)
          {
              if(url.startsWith("mailto:")){
                  MailTo mt = MailTo.parse(url);
                  Intent i = newEmailIntent(activity.this, mt.getTo(), mt.getSubject(), mt.getBody(), mt.getCc());
                  startActivity(i);
                  view.reload();
                  return true;
              }
  
              view.loadUrl(url);
              return true;
          }
  
      });
  }
      public static Intent newEmailIntent(Context context, String address, String subject, String body, String cc) {
          Intent intent = new Intent(Intent.ACTION_SEND);
          intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
          intent.putExtra(Intent.EXTRA_TEXT, body);
          intent.putExtra(Intent.EXTRA_SUBJECT, subject);
          intent.putExtra(Intent.EXTRA_CC, cc);
          intent.setType("message/rfc822");
          return intent;
  }
  </code></pre>
  
  <p>} </p>
  
  <p>After help from people and posts on this site I was able to get a functioning web app that works.  I just need to get the "mailto" functioning and I'm good.  I have tried different code from posts I found.  The above code is getting "IntentSupport cannot be resolved" and "MIME Type cannot be resolved" Just started trying to learn this stuff.  Any feedback would be great. Thanks!</p>