安卓:ACTION_SEND_MULTIPLE与com.android.email [英] Android: ACTION_SEND_MULTIPLE with com.android.email

查看:457
本文介绍了安卓:ACTION_SEND_MULTIPLE与com.android.email的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在意图发送多个附件的电子邮件应用(不是Gmail应用)。我使用的是:

I'm trying to send multiple attachments in an Intent to the Email app (not the Gmail app). I'm using:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "sample@email.com" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"This is an email");
emailIntent.putExtra(Intent.EXTRA_TEXT, "This is the body");

File f1 = null;
File f2 = null;
try {
    f1 = new File("/sdcard/test");
    f2 = new File("/sdcard/test.1");
    FileWriter fw1 = new FileWriter(f1);
    FileWriter fw2 = new FileWriter(f2);
    fw1.write("this is some text");
    fw2.write("this is more text");
    fw1.close();
    fw2.close();
} catch (IOException e) {
    e.printStackTrace();
}

ArrayList<Uri> uris = new ArrayList<Uri>();
uris.add(Uri.fromFile(f1));
uris.add(Uri.fromFile(f2));
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);

startActivity(emailIntent);

在Gmail中用来处理这个意图,它配备了两个附件显示,一切都工作得很好。当电子邮件应用来代替,没有附件添加。当EXTRA_STREAM使用单个URI时,单个附件的工作原理,但使用一个ArrayList没有。我拼凑从问及这里的其他问题这一code,但他们没有解决这个问题。谁能帮助?

When Gmail is used to handle the Intent, it comes up with both attachments showing, and everything works just fine. When the Email app is used instead, no attachments are added. When using a single Uri in EXTRA_STREAM, the single attachment works, but using an ArrayList does not. I've pieced together this code from other questions asked on here, but none of them resolve this issue. Can anyone help?

推荐答案

我知道这是相当晚了,但你的意图类型是倒退。它应该是

I realize that this is quite late, but your intent type is backwards. It should be

emailIntent.setType("text/plain");

不是

emailIntent.setType("plain/text");

我很惊讶,没有其他的答案中指出了这一点......

I'm surprised neither of the other answers pointed that out...

这篇关于安卓:ACTION_SEND_MULTIPLE与com.android.email的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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