【问题标题】:Getting couldn't send attachment error while attaching images with Gmail app [duplicate]使用 Gmail 应用附加图像时出现无法发送附件错误 [重复]
【发布时间】:2015-06-10 08:22:54
【问题描述】:

我有一个从图库中获取的图像文件路径,并且我正在将每个文件路径添加到 ArrayList 中。一切正常,甚至我可以在 Gmail 中看到附件。但是,如果我尝试发送图像。我收到无法发送附件错误。请帮我解决这个问题。我完全坚持解决方案。提前致谢。

图片的路径类似于/storage/emulated/0/myfolder/1433917106851_fact_2.jpg

                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_SEND_MULTIPLE);
                intent.putExtra(Intent.EXTRA_SUBJECT, "Here are some files.");
                intent.setType("image/jpeg"); /* This example is sharing jpeg images. */
                intent.putParcelableArrayListExtra (Intent.EXTRA_STREAM, mShareImages);  //<=== This is the arraylist of images path. 
                startActivity(intent);

注意:mShareImages 是ArrayList&lt;Uri&gt;。我正在通过使用将ArrayList&lt;String&gt; 转换为ArrayList&lt;Uri&gt;

Uri uri = Uri.Parse(string);

最后通过

把这个uri对象加入到ArrayList中
mShareImages.add(uri);

【问题讨论】:

  • 我收到了这个错误。这是因为我的一个文件的路径不正确,所以 gmail 无法读取/附加文件并显示“无法发送附件”。

标签: android image android-intent android-sharing android-fileprovider


【解决方案1】:

您应该将 Uri 列表放入 Intent Extras,而不是 String 列表

【讨论】:

  • s 我也在做同样的事情。检查我编辑的问题
【解决方案2】:

mShareImages 需要是 Uri 类型的 ArrayList 而不是 String。

【讨论】:

    猜你喜欢
    • 2015-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-03
    • 2011-11-15
    • 2018-08-27
    • 1970-01-01
    • 2019-11-14
    相关资源
    最近更新 更多