简体   繁体   English

如何使用附加图像启动电子邮件意图?

[英]How to launch email intent with an attached image?

I am trying to launch an email intent with an attached jpg. 我正在尝试使用附加的jpg启动电子邮件意图。

I did: 我做了:

Intent intent4 = new Intent(Intent.ACTION_SENDTO,
Uri.fromParts("mailto", "testemail@gmail.com", null));
startActivity(intent4);

this launches the email activity. 这将启动电子邮件活动。

But when I try to add DataAndType (my jpeg attachment). 但是当我尝试添加DataAndType(我的jpeg附件)时。 It fails with 它失败了

android.content.ActivityNotFoundException: No Activity found to handle Intent { action=android.intent.action.SENDTO data=file:///data/data/com.mycompany.mypackage/files/temp-picture type=JPEG 


Intent intent4 = new Intent(Intent.ACTION_SENDTO,
  Uri.fromParts("mailto", "testemail@gmail.com", null));
intent4.setDataAndType(Uri.parse("file://"+ mTempFilePath),
  Bitmap.CompressFormat.JPEG.name());    
startActivity(intent4);

您是否尝试手动将mime设置为"image/jpeg"而不是Bitmap.CompressFormat.JPEG.name()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM