You have to handle it yourself in a WebViewClient
public class MyWebViewClient extends WebViewClient {
Activity mContext;
public MyWebViewClient(Activity context){
this.mContext = context;
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.startsWith("mailto:")){
MailTo mt = MailTo.parse(url);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{mt.getTo()});
i.putExtra(Intent.EXTRA_SUBJECT, mt.getSubject());
i.putExtra(Intent.EXTRA_CC, mt.getCc());
i.putExtra(Intent.EXTRA_TEXT, mt.getBody());
mContext.startActivity(i);
view.reload();
return true;
}
view.loadUrl(url);
return true;
}
}
In your activity you keep a reference to MyWebViewClient
and assign it to your webview
with setWebViewClient(mWebClient)
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…