I am taking in an email address via EditText. I got an error saying the address contained whitespaces, no problem. I implemented address.removeAll("\\\\s" , ""); and now am getting the error
Here is my code for capturing the email and converting to a String.
EditText e = (EditText) findViewById(R.id.enterEmail);
String to = e.toString().replaceAll("\\s", "");
On the line where I use the address and get the error:
msg.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(to));
I have done some research trying to find if it is a parsing issue or what would be causing it but found nothing. Anybody know why I would be getting this error? Thanks in advance.
That's because you're converting your EditText
to a String
instead of getting its text and doing the replaceAll()
on it.
Simply replace this:
String to = e.toString().replaceAll("\\s", "");
With this:
String to = e.getText().toString().replaceAll("\\s", "");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.