【发布时间】:2019-10-01 18:25:26
【问题描述】:
在阅读了this question 和this question 之后,我编写了这段代码来为多个地址发送电子邮件:
String[] addresses = {"test@gmail.com", "some@gmail.com" ,"third@gmail.com"};
Intent someIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", Arrays.toString(addresses), null)) //all the addresses
.putExtra(Intent.EXTRA_SUBJECT, "This is a test")
.putExtra(Intent.EXTRA_TEXT, "For my app");
startActivity(Intent.createChooser(someIntent, "Send email..."));
看起来像这样:
正如您在图片中看到的那样,由于某种原因,我收到了第一个电子邮件地址的额外 [ 和最后一个电子邮件地址的额外 ](这导致无效的电子邮件地址,我无法发送电子邮件)。
为什么会发生这种情况以及如何删除那些多余的 [ 和 ]。
【问题讨论】:
-
推测
[和]来自Arrays.toString()。 -
同意 commonsware 我相信这是一个数组字符串
-
感谢您的所有 cmets,CommonsWare 解决了它。有时我确实会犯最愚蠢的错误。