1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| ImageGetter image_getter = new ImageGetter()
{
public InputStream imageFetch(String source) throws MalformedURLException,IOException {
URL url = new URL(source);
Object o = url.getContent();
InputStream content = (InputStream)o;
try
{
Thread.sleep(1000);
} catch (InterruptedException e)
{
BTCore.log("Erreur lors de la mise en pause du thread de téléchargement.");
}
return content;
}
@Override
public Drawable getDrawable(String source) {
Drawable d = null;
try {
InputStream src = imageFetch(source);
d = Drawable.createFromStream(src, "src");
if(d != null){
d.setBounds(0,0,(d.getIntrinsicWidth()), d.getIntrinsicHeight());
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Log.e("Bluetech","chargement de l'image: "+source);
return d;
}
};
emailIntent .putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml("<div><img src='http://www.foo.com/goo.png'/><b>bla bla bla</b></div>",image_getter,null)); |
Partager