注:我不想圖像附加到電子郵件如何在電子郵件正文中顯示圖片?
我想在電子郵件正文中顯示的圖像,
我曾試圖HTML圖像標記<img src=\"http://url/to/the/image.jpg\">"
和我輸出,你可以看到我的問題在How to add an image in email body,所以我累Html.ImageGetter
。
它不工作對我來說,這也給了我同樣的輸出,所以我有一個疑問是有可能做到這一點,
我的代碼
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;
}
};
更新1:如果我用的是ImageGetter
代碼TextView
我能夠得到的文本和圖像,但我無法看到在電子郵件正文
這裏的形象是我的代碼:
TextView t = null;
t = (TextView)findViewById(R.id.textviewdemo);
t.setText(Html.fromHtml("Hi <img src='http://url/to/the/image.jpg'>",
imgGetter,
null));
更新2:我用了大膽的標記,錨標記如圖所示,這些標籤下面我工作正常,但是當我使用img標籤,我可以看到一個方形盒子,其稱作爲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));
你有沒有試着用另一標籤?當它來自一個意圖時,它可能會被消毒。 – Macarse 2011-06-02 12:22:47
@Macarse:哪個標籤,你可以詳細說明 – 2011-06-02 12:29:01
@Sankar:例如一個大膽的標籤。只是爲了測試它是否有效。 – Macarse 2011-06-02 12:39:15