简体   繁体   English

对于GMail,通过Android的Intent发送附加到电子邮件的zip文件失败

[英]Sending a zipfile attached to email via Android's Intent fails for GMail

Intent intent = new Intent(Intent.ACTION_SEND,Uri.fromParts("mailto:","abc@gmail.com", null));
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"<email@example.com>"}); 
intent.putExtra(Intent.EXTRA_SUBJECT, "<Subject here>");
intent.putExtra(Intent.EXTRA_TEXT, "<Body text here>");

intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" +     CachedFileProvider.AUTHORITY + "/" +files[0].getName()));
startActivity(Intent.createChooser(intent, "Send email..."));

I succeed to attach a plain text file but a zipped file fails with the message 我成功附加了纯文本文件,但压缩文件失败,并显示以下消息

not possible to attach empty file 无法附加空文件

in the Gmail client. 在Gmail客户端中。

Tried to set Intent.setType("application/zip") etc. 试图设置Intent.setType("application/zip")等。

I left out the parcable code included to allow sending cached files 我省略了包含的可分析代码,以允许发送缓存的文件

Any suggestions? 有什么建议么?

Solved. 解决了。

Uri a = Uri.fromFile(Zipfile);
intent.putExtra(Intent.EXTRA_STREAM, a);

Simpy adding a zipped file from cache the extra parcel handling not needed. Simpy从缓存中添加压缩文件不需要额外的包裹处理。

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

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