大佬教程收集整理的这篇文章主要介绍了Android:ACTION_SEND_MULTIPLE与com.android.email,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将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[] { "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用于处理Intent时,它会显示两个附件,并且一切正常.使用电子邮件应用程序时,不会添加任何附件.在EXTRA_STREAM中使用单个Uri时,单个附件可以工作,但使用ArrayList则不行.我把这个代码拼凑在这里提出的其他问题中,但没有一个能解决这个问题.有人可以帮忙吗?
解决方法:
使用
emailIntent.setType(" */ * ");
没有空格
see here ACTION_SEND_MULTIPLE
以上是大佬教程为你收集整理的Android:ACTION_SEND_MULTIPLE与com.android.email全部内容,希望文章能够帮你解决Android:ACTION_SEND_MULTIPLE与com.android.email所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。