如何启动电子邮件的意图有一个附加的形象呢? [英] How to launch email intent with an attached image?

查看:87
本文介绍了如何启动电子邮件的意图有一个附加的形象呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图启动电子邮件意图与一个附加的JPG。

我所做的:

 意图int​​ent4 =新的意图(Intent.ACTION_SENDTO,
Uri.fromParts(电子邮件地址,testemail@gmail.com,NULL));
startActivity(intent4);
 

这将启动电子邮件活动。

但是,当我尝试添加DataAndType(我的JPEG格式附后)。它失败,

  android.content.ActivityNotFoundException:无活动处理意向{行动= android.intent.action.SENDTO数据=文件:///data/data/com.mycompany.mypackage /文件/温度画面类型= JPEG


意图int​​ent4 =新的意图(Intent.ACTION_SENDTO,
  Uri.fromParts(电子邮件地址,testemail@gmail.com,NULL));
intent4.setDataAndType(Uri.parse(文件://+ mTempFilePath)
  Bitmap.Com pressFormat.JPEG.name());
startActivity(intent4);
 

解决方案

你有没有尝试手动设置默为为image / jpeg而不是 Bitmap.Com pressFormat.JPEG.name()

I am trying to launch an email intent with an attached 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). 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);

解决方案

Did you try setting the mime manually to "image/jpeg" instead of Bitmap.CompressFormat.JPEG.name().

这篇关于如何启动电子邮件的意图有一个附加的形象呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆