如何在 android webview 中处理 mailto[HTML]

How to handle mailto[HTML] in android webview

我在 HTML 页面中有一个 href link,我 link 将这样的电子邮件地址发送到:

<p>sometext <a href="mailto:mymailadresse@gmail.com">mymailadresse@gmail.com</a></p>

这是我的 android MainActivity:

import android.app.Activity; 
import android.os.Bundle; 
import android.view.KeyEvent; 
import android.webkit.WebChromeClient; 
import android.webkit.WebView; 
import android.webkit.WebViewClient;

import com.google.android.gms.common.api.GoogleApiClient;

public class MainActivity extends Activity {

/**
 * ATTENTION: This was auto-generated to implement the App Indexing API.
 * See https://g.co/AppIndexing/AndroidStudio for more information.
 */
private GoogleApiClient client;
private WebView view;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    view = (WebView) this.findViewById(R.id.webView);
    view.getSettings().setJavaScriptEnabled(true);
    view.getSettings().setDomStorageEnabled(true);
    view.setWebViewClient(new MyBrowser());
    view.loadUrl("file:///android_asset/www/index.html"); //try js alert
    view.setWebChromeClient(new WebChromeClient()); // adding js alert 


}

/**
 * ATTENTION: This was auto-generated to implement the App Indexing API.
 * See https://g.co/AppIndexing/AndroidStudio for more information.
 */

private class MyBrowser extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK) && view.canGoBack()) {
        view.goBack(); //method goback()
        return true;
    }

    return super.onKeyDown(keyCode, event);
    }
}

我知道我需要对主要 activity 做些什么,但我不知道该做什么?那么有人可以帮我吗?

提前致谢!

内部 shouldOverrideUrlLoading() 方法使用了这个逻辑

  if (url.startsWith("tel:") || url.startsWith("sms:") || url.startsWith("smsto:") || url.startsWith("mailto:") || url.startsWith("mms:") || url.startsWith("mmsto:")) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(intent);
                return true;
            }
  else {
         view.loadUrl(url);
       }