【问题标题】:Sending image through email intent permissions or not able to locate file?通过电子邮件意图权限发送图像或无法找到文件?
【发布时间】:2013-04-27 19:42:42
【问题描述】:

我正在捕获相对布局的绘图缓存并将其保存到文件中。该文件已经过测试并且存在。使用此文件,我将图像作为电子邮件附件发送,但它不起作用。之前它曾经说由于路径不正确而无法找到它,但是我修复了它,现在 logcat 中没有错误。这是否是由于缺少权限、无法定位文件或发送 Android 不支持的电子邮件图片附件造成的?

保存图片

    ImagePlace.setDrawingCacheEnabled(true);
    Bitmap picture = ImagePlace.getDrawingCache();
    try {       
    System.out.println(this.getActivity().getApplicationContext().getCacheDir());
picture.compress(CompressFormat.JPEG, 95, new FileOutputStream(new File(this.getActivity().getApplicationContext().getFilesDir(),"asdasdasdasdasdas.jpg")));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch blockm
e.printStackTrace();
}

启动电子邮件意图

  Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
  emailIntent.setType("image/*");
  emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Projectile Motion Solution");
  emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(html));
 // emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://your.package.name/" + R.raw.background));
   emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(this.getApplicationContext().getFilesDir()+"asdasdasdasdasdas.jpg"));
  startActivity(emailIntent);  

【问题讨论】:

  • 我也尝试使用图像标签(将其添加为 HTML)并遇到了同样的问题。它没有给我一个找不到文件的错误。

标签: android image email android-intent bitmap


【解决方案1】:

试试这个

Uri.parse("file://" + 文件路径)); 反而 的 uri.parse(this.getApplicationContext().getFilesDir()+"asdasdasdasdasdas.jpg"));

【讨论】:

  • 还是不行。它给了我一个空图像图标作为附件中的缩略图。
  • 你能在你的设备中看到保存的图像吗?
  • 作为缩略图,但我无法打开它。
  • 好的,可能是文件格式不受它支持或文件已损坏。尝试发送存储在存储卡某处的有效 jpeg .. 通过意图
猜你喜欢
  • 2013-12-01
  • 2013-02-21
  • 2018-09-20
  • 1970-01-01
  • 2012-04-24
  • 1970-01-01
  • 1970-01-01
  • 2021-04-10
  • 2012-01-31
相关资源
最近更新 更多