-6

How to make sure the user type "@yahoo" or"@gmail" in an edit text(email) and intent the information to the next page. What I want to do is: make a page for the user to open a fake account and put in all the information and then, intent all the information to the next page. Make the user feels like he/she had opened an account. And now my question is: how to confirm that the user had type in "xxx@xxx.com" in the edit text to prevent he/she knows it's fake. Any kinds of solutions will help.

  • Why do every one dislike my question... – Stupid_Genius Nov 20 '14 at 12:19
  • 2
    This site is great because it's NOT a "please give me code" site, rather it works well when you have a clear question preferably with some example code. Requests for complete solutions are generally frowned upon. – djv Nov 24 '14 at 15:24
  • http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#matches(java.lang.String) – mustaccio Nov 24 '14 at 16:21

3 Answers3

1

you can do this by checking "yahoo" or "gmail" or ... in the string you get from the edit text like this:

 if (strMessage.contains("@gmail.com") || strMessage.contains("@yahoo.com"){
//Do whatever you want.
}
Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
0

Use

{
android.util.Patterns.EMAIL_ADDRESS.matcher("Your xxx@xxx.com").matches();
}

this will return boolean

Mourice
  • 597
  • 1
  • 5
  • 17
0

First set check to your "email" or "gmail", then use an if statement

if (editText.contains("@")){

 Your code

}
Taryn
  • 242,637
  • 56
  • 362
  • 405