Note: I don't want to attach the Image to the Email
I want to show an image in the email body,
I had tried the HTML image tag <img src=\"http://url/to/the/image.jpg\">"
and I got output as you can see in this my question on How to add an image in email body, so I tired Html.ImageGetter
.
It does not work for me, it also gives me the same output, so I have a doubt is it possible to do this,
My code
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_EMAIL,new String[] {"[email protected]"});
i.putExtra(Intent.EXTRA_TEXT,
Html.fromHtml("Hi <img src='http://url/to/the/image.jpg'>",
imgGetter,
null));
i.setType("image/png");
startActivity(Intent.createChooser(i,"Email:"));
private ImageGetter imgGetter = new ImageGetter() {
public Drawable getDrawable(String source) {
Drawable drawable = null;
try {
drawable = getResources().getDrawable(R.drawable.icon);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight());
} catch (Exception e) {
e.printStackTrace();
Log.d("Exception thrown",e.getMessage());
}
return drawable;
}
};
UPDATE 1: If I use the ImageGetter
code for TextView
I am able to get the text and image but I am not able to see the image in the email body
Here is my code:
TextView t = null;
t = (TextView)findViewById(R.id.textviewdemo);
t.setText(Html.fromHtml("Hi <img src='http://url/to/the/image.jpg'>",
imgGetter,
null));
UPDATE 2: I had used bold tag and anchor tag as i shown below these tag are working fine , but when i used img tag i can able to see a square box which say as OBJ
i.putExtra(Intent.EXTRA_TEXT,Html.fromHtml("<b>Hi</b><a href='http://www.google.com/'>Link</a> <img src='http://url/to/the/image.jpg'>",
imgGetter,
null));