gpt4 book ai didi

Android 电子邮件用加号 (+) 替换空格

转载 作者:行者123 更新时间:2023-11-29 15:26:30 25 4
gpt4 key购买 nike

我在操作 View 中发送电子邮件,它在 gmail 中工作得很好,但如果用户选择任何其他邮件服务,它会将空格替换为“+”

like in body text is "check out it is a good day"

it displays as "check+out+it+is+a+good+day"

知道如何解决这个问题

这是我发送邮件的功能

private void sendToAFriend() {

String subject = "it is a good day ";
String body = "Check out it is a good day";

String uriText =
"mailto:" +
"?subject=" + URLEncoder.encode(subject) +
"&body=" + URLEncoder.encode(body);

Uri uri = Uri.parse(uriText);

Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
startActivity(Intent.createChooser(sendIntent, "Send email"));
}

最佳答案

试试这段代码。

Intent intent = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject of email");
intent.putExtra(Intent.EXTRA_TEXT, "Body of email");
intent.setData(Uri.parse("mailto:default@recipient.com")); // or just "mailto:" for blank
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this will make such that when user returns to your app, your app is displayed, instead of the email app.
startActivity(intent);

关于Android 电子邮件用加号 (+) 替换空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12172338/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com