HTML links disappear from email created with Intent (Android 4.1+)

I encountered a problem occurring on Android 4.1+ devices. I want to send an email (via Intent ) containing html links. I know this works on Android 2.x devices because I have been doing this for several months.

Here is the java code:

 startActivity(Intent.createChooser( new Intent(Intent.ACTION_SEND) .putExtra(Intent.EXTRA_SUBJECT, "A subject") .setType("text/html") .putExtra(Intent.EXTRA_TEXT, Html.fromHtml("Some text ... <a href="http://www.weburl.com">Some text</a>)), "Email")); 

In Android 4.1: When I use this code, Gmail shows the text as expected, AND I SEE LINKS in blue underlined. But I get this mail without links.

In Android 2.x: Everything is perfect. I get an email with links

Can someone help me solve this problem?

+4
source share
1 answer

I think email applications do not have full html support. I have the following code:

 Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto","", null)) .putExtra(Intent.EXTRA_SUBJECT, "LIJSTJE fb") .putExtra(Intent.EXTRA_TEXT, Html.fromHtml(new StringBuilder() .append("<p style='font-weight:bold;'>Some Content</p>") .append("<a>http://www.google.com</a><br/>") .append("<a href='http://www.facebook.com'>facebook</a>") .append("<small><p>More content</p></small>") .toString())); startActivity(Intent.createChooser(emailIntent, "Send email...")); 

Items and new lines are added as expected. Style, however, is not. Also, when you type the full URL, you get a link, but when you do it like a facebook link, you don’t.

I suspect that the email client on the phone removes the styles and makes the link to the visible text a link. Thus, the user knows where the link goes. Also, if you think about it, the native gmail application has no style options. Thus, this can erase the style of styles.

At least my theory. :)

(NOTE: I tested only in the Gmail app!)

I also changed the Intent type from SEND to SENDTO so that it only uses email clients and not other applications. And I deleted the setType () method, because when you use it, you get an "application not found" error.

+4
source

All Articles