【问题标题】:Attaching an drawable image to email in android在android中将可绘制图像附加到电子邮件
【发布时间】:2012-03-28 02:45:45
【问题描述】:

我的应用程序中有一个可绘制图像列表,并希望通过邮件发送其中一个图像。 我的代码看起来像

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/*");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Picture");                       
sendIntent.putExtra(Intent.EXTRA_STREAM,
                    Uri.parse(lstPhotos.get(newPosition).getPhotoURL()));
myActivity.startActivity(Intent.createChooser(sendIntent, "Email:"));

但是在上面的代码中我遇到了一个问题,因为我无法从可绘制列表中获取图像 URI。 谁能帮助我如何发送图像,因为如果我使用上面的代码,我会收到一个 0kb 的空图像。

【问题讨论】:

    标签: android image email android-intent drawable


    【解决方案1】:

    您可以通过将该图像作为图像保存到内部/外部 cache 目录中的临时位置,然后使用 Uri 在附件中使用该图像的路径来实现。

    【讨论】:

      猜你喜欢
      • 2016-12-29
      • 1970-01-01
      • 1970-01-01
      • 2010-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多