Reputation: 5189
I get a server response which provides us with HTML to be sent via gmail. This works fine on the iOS counterpart of the app, however the text just comes out as plain text in the Android application.
Here is an example part of the response we get:
<html>
<p style="color: #5987c6">My Shared Itinerary - John Smith.</p>
<p>Hello.</p>
<p>I want to share my Memmingen, DE trip itinerary with you.</p>
<p>Shared using
<span style="color: #5987c6">Blah</span> by BlahBlah
</p>
</html>
And I have tried doing the following:
final Intent shareIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
shareIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(new StringBuilder().append(testBody).toString()));
Where testBody is set to the example I gave above. I was just wondering is it possible to have this work straight away with the response from the server, or will I have to do some reformatting once it is received? Thanks for any help
Upvotes: 1
Views: 2852
Reputation: 1007296
I get a server response which provides us with HTML to be sent via gmail.
No, it will be "sent" by the app of the user's choosing, from any of the apps on the device that support ACTION_SENDTO
on a mailto:
Uri
. Or, the user could choose to not send the email at all.
however the text just comes out as plain text in the Android application
It is up to the app that the user chooses to handle your request to determine what to do with your content.
You can maximize the odds of this working by:
Using EXTRA_HTML_TEXT
along with EXTRA_TEXT
, where EXTRA_HTML_TEXT
has the raw HTML
Using HTML that fits with what Html.fromHtml()
supports, which notably does not include span
tags or style
attributes.
Neither of these steps guarantees that Gmail, or any other app, will necessarily faithfully render and use your HTML-formatted message, but they should help.
Upvotes: 2