我正在尝试将 Intent 中的多个附件发送到电子邮件应用程序(而不是 Gmail 应用程序)。我在用着:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "[email protected] /cdn-cgi/l/email-protection" });
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 用于处理 Intent 时,它会显示两个附件,并且一切正常。当使用电子邮件应用程序时,不会添加任何附件。在 EXTRA_STREAM 中使用单个 Uri 时,单个附件有效,但使用 ArrayList 则无效。我从这里提出的其他问题中拼凑了这段代码,但没有一个解决这个问题。有人可以帮忙吗?
use
emailIntent.setType(" */ * ");
没有空格
see here http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND_MULTIPLEACTION_SEND_MULTIPLE
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)