Android电子邮件会用加号(+)替换空格 [英] Android email replaces space with plus(+)
本文介绍了Android电子邮件会用加号(+)替换空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在操作视图中发送了一封电子邮件,它在gmail中运行得非常好,但是如果用户选择任何其他邮件服务,它会用'+'替换空格。
<$ p
它显示为check + out + it + is + a + good + day$ p $ 在正文中显示为check out it is a good day
b $ b
任何想法如何解决这个问题
这是我发送电子邮件的函数
private void sendToAFriend(){
String subject =it是美好的一天;
String body =看看这是一个美好的一天;
String uriText =
mailto:+
?subject =+ URLEncoder.encode(subject)+
& body =+ URLEncoder。编码(主体);
Uri uri = Uri.parse(uriText);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
startActivity(Intent.createChooser(sendIntent,发送电子邮件));
解决方案
试试这段代码。 p>
Intent intent = new Intent(Intent.ACTION_SENDTO); //它不是ACTION_SEND
intent.setType(text / plain);
intent.putExtra(Intent.EXTRA_SUBJECT,邮件主题);
intent.putExtra(Intent.EXTRA_TEXT,Body of email);
intent.setData(Uri.parse(mailto:default@recipient.com)); //或只是mailto:为空
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //这会使用户返回到应用程序时显示应用程序,而不是电子邮件应用程序。
startActivity(intent);
I am sending an email in action view, it works perfectly fine in gmail , but if the user chooses any other mailing service it replaces spaces with '+'
like in body text is "check out it is a good day"
it displays as "check+out+it+is+a+good+day"
Any idea how to solve this issues
Here is my function for sending email
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"));
}
解决方案
Try this code.
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电子邮件会用加号(+)替换空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文