WebView不支持高级HTML标记…您需要做的是:
>将webclient设置为您的webview并覆盖url加载
>当您检测到邮件链接时,尝试发送电子邮件.
我要给您一些代码片段,让您有个想法.请记住,这只是一个基本示例,我现在无法对其进行测试:
public void onCreate(Bundle icicle) {
// blablabla
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient( new YourWebClient());
// blablabla
}
private class YourWebClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view,String url) {
if (url.contains("mailto")) {
// TODO: extract the email... that's your work,LOL
String email = "";
sendEmail();
return super.shouldOverrideUrlLoading(view,url);
}
view.loadUrl(url);
return true;
}
}
然后,发送电子邮件:
public void sendEmail(String email){
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{email});
String mySubject = "this is just if you want";
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,mySubject);
String myBodyText = "this is just if you want";
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,myBodyText);
context.startActivity(Intent.createChooser(intent,"Send mail...));
}