我有一个加载在webViewActivity中的文档,在本文档中我有我的电子邮件ID。当用户点击我的电子邮件ID时,我想打开电子邮件应用,请帮助我。
This is sample document.
This is text contained in document. if you have any queries please contact me at mailto@examplemail.com
答案 0 :(得分:2)
试试这个:
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//Check whether url contains email or not.
// To start Email Intent
String[] mailto = { "example.com" };
// Create a new Intent to send messages
Intent sendIntent = new Intent(Intent.ACTION_SEND);
// Add attributes to the intent
sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "This is sample document.");
sendIntent.setType("message/rfc822");
startActivity(sendIntent);
return true;
}
希望这有帮助。