将图片附加到电子邮件

时间:2011-04-13 10:47:28

标签: android email android-intent attachment

任何人都知道如何使用

附加图像
Intent intent = new Intent(Intent.ACTION_SENDTO); 

我知道如何使用Intent.ACTION_SEND,但我想使用SENDTO删除用户的蓝牙选项。

当我没有附上图片但我使用

时,我的工作正常
intent.setData(pictureUri);

它告诉我没有任何申请来完成这项工作。

感谢您的帮助。

修改

插入我现在拥有的代码。它“工作正常”,但图像没有附加。

代码

intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/html");
Uri uri = Uri.parse("mailto:?");
intent.setData(uri);
intent.putExtra(Intent.EXTRA_STREAM, picture);
intent.putExtra("subject", subject );
context.startActivity(Intent.createChooser(intent, "Share Via:"));

picture是电话上图片的Uri。

任何人都知道会出现什么问题?

2 个答案:

答案 0 :(得分:2)

尝试:

i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(pic));

答案 1 :(得分:1)

根据API文档,SENDTO期望数据字段中的收件人,而不是附件。 通过说intent.setData(pictureUri),您基本上是在尝试向图片发送消息。 See here

SEND通过附加功能接受附件,因此您可以尝试使用SENDTO。

例如:

intent.putExtra(Intent.EXTRA_STREAM, pictureUri);
相关问题