如何在android中将多个文件附加到电子邮件客户端 [英] how to attach multiple files to email client in android
本文介绍了如何在android中将多个文件附加到电子邮件客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Intent .ACTION_SEND
来获取默认的电子邮件客户端.它工作正常,但现在我需要将多个文件附加到电子邮件中.
I am using Intent .ACTION_SEND
to get default email client. It works fine but now i need to attach more than one file to email.
email.putExtra(android.content.Intent.EXTRA_STREAM,...)
仅附加最后添加的 uri.
email.putExtra(android.content.Intent.EXTRA_STREAM,...)
attaches only last uri added to it.
那么我可以附加多个文件吗?我认为这可以通过使用 Intent.ACTION_SEND_MULTIPLE
来完成.这是我正在尝试的代码:
So can I attach multiple files? I think this can be done by using Intent.ACTION_SEND_MULTIPLE
. Here is the code I am trying:
String uri=getScreenShot();
Intent email = new Intent(android.content.Intent.ACTION_SEND);
email.setType("application/octet-stream");
email.putExtra(Intent.EXTRA_STREAM, Uri.parse(uri));
email.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file:"+csvpath));
alert.dismiss();
ctx.startActivity(Intent.createChooser(email, "Send mail..."));
提前致谢.
推荐答案
有效:
final Intent ei = new Intent(Intent.ACTION_SEND_MULTIPLE);
ei.setType("plain/text");
ei.putExtra(Intent.EXTRA_EMAIL, new String[] {"me@somewhere.nodomain"});
ei.putExtra(Intent.EXTRA_SUBJECT, "That one works");
然后添加文件的 uri:
then add files' uris:
ArrayList<Uri> uris = new ArrayList<Uri>();
ei.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivityForResult(Intent.createChooser(ei, "Sending multiple attachment"), 12345);
希望有所帮助.
这篇关于如何在android中将多个文件附加到电子邮件客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文