Basic user registration With Email Verification

After this tutorial, you will able to build a user system similar to the example below.





Before you start. Make sure you have read the Quickstart and Basic User Registration tutorials.



Basic user registration

Step 1 – Enable Email Verification


To Enable Email Verification simply login -> Features -> Verification e-mails -> Server

Verification emails


Enable Verify User Emails by checking the box.
Verify User Emails



Step 2 – Implementing register function

In order to implement the register function you may place it inside a click action of a Button, like this:


Button mEmailSignInButton = (Button) findViewById(;
mEmailSignInButton.setOnClickListener(new OnClickListener() {
    public void onClick(View view) {
        try {
        } catch (Exception e) {


The attemptRegister() function will need to be implemented, for example:

private void attemptRegister() {
    // Reset errors.

    // Store values at the time of the login attempt.
    String email = mEmailView.getText().toString();
    String password = mPasswordView.getText().toString();

    boolean cancel = false;
    View focusView = null;

    // Check for a valid password, if the user entered one.
    if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
        focusView = mPasswordView;
        cancel = true;

    // Check for a valid email address.
    if (TextUtils.isEmpty(email)) {
        focusView = mEmailView;
        cancel = true;
    } else if (!isEmailValid(email)) {
        focusView = mEmailView;
        cancel = true;

    if (cancel) {
        // There was an error; don't attempt login and focus the first
        // form field with an error.
    } else {
        ParseUser user = new ParseUser();
        user.signUpInBackground(new SignUpCallback() {
            public void done(ParseException e) {
                if (e == null) {
                    final String title = "Account Created Successfully!";
                    final String message = "Please verify your email before Login";

                    alertDisplayer(title, message);
                } else {
                    final String title = "Error Account Creation failed";
                    final String message = "Account could not be created";
                    alertDisplayer(title, message + " :" + e.getMessage());


The red part of code represent the strings that you can set in your strings.xml file. The green part of the code are functions for validation of the email and password, for example:

    private boolean isEmailValid(String email) {
        return email.contains("@");

    private boolean isPasswordValid(String password) {
        return password.length() > 4;


After enabling the Email verification function and setting the email to user the register function will automatically send the email to target email.


Step 3 – Implementing login function


As we need to know the user have verified the E-mail or not, we need to alter the previous basic login function.

void parseLogin() {
        ParseUser.logInInBackground(mUsernameView.getText().toString(), mPasswordView.getText().toString(), new LogInCallback() {
            public void done(ParseUser parseUser, ParseException e) {
                if (parseUser != null) {
                    if(parseUser.getBoolean("emailVerified")) {
                    else {
                        alertDisplayer("Login Fail", "Please Verify Your Email first");
                } else {
                    alertDisplayer("Login fail", e.getMessage()+ "Please retry");


The red part of code is a simple condition check for the emailVerified field of the specific user. It will proceed with the login if the email verification is done or log the user out if the email wasn’t verified.

Special Step


To check a functional email verification android app check the link below:
Android Login Email Verification