6

I have one html to display image as base64 :

    <html><body>hello<br/><img style='display:block; width:100px;height:50px;' id='base64image' src='data:image/png;base64,<!-base 64 string-->' /></body></html>

the result is this:

enter image description here

but when i use this in Email like this:

Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.setType("text/html");
String body = new String("<html><body>hello<br/><img style='display:block; width:100px;height:50px;' id='base64image' src='data:image/png;base64,<!-base 64 string-->' /></body></html>");
email.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
startActivity(Intent.createChooser(email,"Choose an Email client :"));

The result is like below:

enter image description here

image is not display in mail. is there something that I am missing here. is there any limit to pass the base64 data or something other issue is here?.

Beena
  • 2,334
  • 24
  • 50
KDeogharkar
  • 10,939
  • 7
  • 51
  • 95

2 Answers2

0

Not sure if this would work but try using this

email.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));

insted of

email.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
Manishika
  • 5,478
  • 2
  • 22
  • 28
0

Unfortunately, it's not possible to do this with Intents.

The reason why for example bold text is displayed in the EditText and not an Image is that StyleSplan is implementing Parcelable whereas ImageSpan does not. So when the Intent.EXTRA_TEXT is retrieved in the new Activity the ImageSpan will fail to unparcel and therefor not be part of the style appended to the EditText.

Using other methods where you don't pass the data with the Intent is unfortunately not possible here as you're not in control of the receiving Activity.

I search lot for this issue and i found a very good answer at this link :

https://stackoverflow.com/a/7550813/1186689

It gives the answer and also clear all doubts.

Community
  • 1
  • 1
KDeogharkar
  • 10,939
  • 7
  • 51
  • 95
  • Does that mean if one would implement Parcelable for the ImageSpan it should work? I don't really have the time now but just wondering. This limitation is very annoying – momo Sep 18 '13 at 08:16
  • you dont have control on intent that called. how will you pass parcelable? – KDeogharkar Sep 19 '13 at 03:58