<a href='mailto:info@company.com'>info@company.com</a>
这段话放在webView中在模拟器上不行,可是在设备上可以郁闷。
myTemplate ="<a>info@company.com</a>"; 或者
myTemplate ="info@company.com";
mWebView.loadDataWithBaseURL(null, myTemplate, "text/html", "utf-8", null);
2.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...));
}