I am not 100% sure if you mean how to check if a string is a valid email address or how to authenticate a user using an email address.
If you want to check the correctness of the entered email address, I would recommend you to use the utility class Patterns :
String email = " john.doe@gmail.com "; if(Patterns.EMAIL_ADDRESS.matcher(email).matches()) { // e-mail is valid } else { // e-mail is invalid }
If you want to authenticate a user using an email address, I really recommend that you look at how to authenticate a user using oAuth2 and one of the Google accounts on the device. Google engineer Tim Bray wrote a very simple guide to checking internal calls from Android on the Google Developer Blog.
UPDATE: Since you are requesting a way to authenticate your Google or Yahoo account, I will update my answer here:
First of all, I would never let a third-party application know the password for my email account. In addition, it would be absolutely insane to ask the gmail username and password if you are more or less guaranteed to have at least one of them on your Android device. Check out my previous link to find out how to log in using your Google account without having to ask for a password from the user. Yahoo seems to have oAuth support . And it seems that there are already a few questions regarding how to integrate this into Android .
source share