本文介绍了如何将多个文件以电子邮件客户端的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用意图.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
来完成。这里是code我想:
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..."));
在此先感谢。
Thanks in advance.
推荐答案
这工作:
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);
希望有所帮助。
Hope that helps.
这篇关于如何将多个文件以电子邮件客户端的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!