This is a simple example showing email validation in ANDROID.
This example uses regex for email validation.
Create a button and an edittext in your main.xml file and try this code.

package com.coderzheaven;

import java.util.regex.Pattern;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class EmailValidationDemo extends Activity   {

	EditText TF;
	public Button checkButton;

	public final Pattern EMAIL_ADDRESS_PATTERN = Pattern.compile(
	          "[a-zA-Z0-9+._%-+]{1,256}" +
	          "@" +
	          "[a-zA-Z0-9][a-zA-Z0-9-]{0,64}" +
	          "(" +
	          "." +
	          "[a-zA-Z0-9][a-zA-Z0-9-]{0,25}" +
     public void onCreate(Bundle savedInstanceState) {

	   TF=(EditText) findViewById(;
	   checkButton=(Button) findViewById(;

	    checkButton.setOnClickListener(new OnClickListener() {
		public void onClick(View v) {
			   String email=TF.getText().toString();
				  Toast.makeText(EmailValidationDemo.this,"Valid Email Addresss", Toast.LENGTH_SHORT).show();
			 	  Toast.makeText(EmailValidationDemo.this,"Invalid Email Addresss", Toast.LENGTH_SHORT).show();
    private boolean checkEmail(String email) {
        return EMAIL_ADDRESS_PATTERN.matcher(email).matches();

Check this link to find how you can send email from android programatically.
Please leave your valuable comments……



  1. Farhan Mehmood May 3, 2011 at 4:31 pm

    yeah! worked like a chram! (^_^) thank u so much!

  2. SATRASALA VINIL June 14, 2011 at 11:54 am

    Thank u so much.. but can u make it to complete file please,, so that the user can know about the exceptions in manifest file also

  3. Shreya June 23, 2011 at 2:39 am

    I’m developing an android app where I’m storing encrypted password(md5) in database using php script. I can successfully insert encrypted password it in database but cannot check it with the value I’m entering in login form. So can you please tell me how to encrypt password in android?

    • James June 23, 2011 at 6:15 am

      Hi Shreya……

      We will check that.

    • James June 23, 2011 at 10:48 pm

      Hello Shreya, You can encrypt the password using the “Cipher” class in android.

  4. TechnoTalkative July 7, 2011 at 10:16 pm


    I have implemented the example and tested it, it was working fine in most cases, but when i tried to test , then it is showing “Valid Email Addresss”. I have not entered .com/.org/.co or any else still it is showing its valid.

    • James July 7, 2011 at 10:24 pm

      ok TechnoTalkative..
      We will rectify it.
      Thanks for the information.

  5. Ranjith August 30, 2011 at 2:27 pm

    i am using it showing valid email..

    • James August 30, 2011 at 2:52 pm

      OK Ranjtih we will check that. most probably we might have missed that combination.

  6. nami October 24, 2013 at 11:45 am

    ya in my came whatever m typing with its showing valid…otherwise invalid


Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.