这是我在 Android 中发送 HTML 电子邮件的代码,带有可点击的链接。
private void sendEmail()
{
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String subject = "Prueba";
String emailtext = "<a href=http://www.google.es>PruebaEmail</a>";
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(emailtext.toString()));
startActivity(Intent.createChooser(emailIntent, "Send mail"));
}
几个月前,它可以正常工作并发送一个可点击的超链接,但现在,当我在我的 GMail 帐户中收到邮件时,没有超链接,只有纯文本。
我已经尝试过所有这些类型:
emailIntent.setType("message/rfc822");
and
emailIntent.setType("plain/text");
and
emailIntent.setType("text/html");
正文如下:
String emailtext = "<a href=http://www.google.es>PruebaEmail</a>";
and
String emailtext = "<a href='http://www.google.es'>PruebaEmail</a>";
and
String emailtext = "<a href="http://www.google.es">PruebaEmail</a>";
但这些都不起作用。
这个问题仅适用于 GMail,因为如果我将邮件发送到 Evernote 或其他应用程序,我会得到一个可点击的链接。
这是我的 API 配置:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8"/>
并使用Android 3.2进行编译
有任何想法吗?