【发布时间】:2012-10-05 07:49:56
【问题描述】:
我正在使用此代码附加文件:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO);
String uriText;
Uri file = Uri.fromFile(new File(path));
uriText = "mailto:" +
"?subject=the subject" +
"&body=the body of the message"+
"&attachment="+file;
uriText = uriText.replace(" ", "%20");
Uri uri = Uri.parse(uriText);
emailIntent.setData(uri);
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
(请注意,path 类似于“/sdcard/test.jpg”,我使用了ACTION_SENDTO,因为我只想在选择器中查看电子邮件应用程序。)
意图将提供电子邮件应用程序列表,但附件不会出现在电子邮件或 Gmail 中。如何让附件显示?
【问题讨论】:
-
这里有同样的东西。找不到使用 ACTION_SENDTO 将文件附加到电子邮件的方法。使用 ACTION_SEND 可以处理附件,但会显示大量废话。
-
您应该使用 Uri.Builder() 来创建该 uriText
-
花了几天时间解决这个问题...现在有更新吗?