tags:

views:

83

answers:

1

From an Android app, I'm trying to send an email with an HTML body with an embedded img. From what I've read, the following should work. The email is received with HTML bold tags working correctly etc, however the img is replaced with [OBJ]. My logging tells me that I do indeed get a Drawable with the correct dimensions etc, so it seems that the local email client is not understanding the image in the Spannable. Is there some trick such as images need to come from "content:" URIs? thanks!

Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_SUBJECT, "Sample subject");
i.setType("text/html");
Spanned html =
    Html.fromHtml(
        "<html><body>h<b>ell</b>o<img src='http://www.pp.rhul.ac.uk/twiki/pub/TWiki/GnuPlotPlugin/RosenbrockFunctionSample.png'&gt;world&lt;/body&gt;&lt;/html&gt;",
        new ImageGetter() {
            public Drawable getDrawable(String url) {
                InputStream s = (InputStream) (new URL(url)).getContent();
                Drawable d = Drawable.createFromStream(s, null);
                LogUtil.debug(this, "Got image: " + d.getClass() + ", " + d.getIntrinsicWidth() + "x" + d.getIntrinsicHeight());
                d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
                return d;
             }
        ),
        null
    );
i.putExtra(Intent.EXTRA_TEXT, html);
startActivity(Intent.createChooser(i, "Send email"));