Email Registration Verification Android Studio – In this article i will explain user registration email verification android application in Android Studio. Every android application need registration login form its mandatory and also very important for email verification whether its valid email account or not. So here develop the simple login & registration with email verification.
When the user register enter his email-id, the mail send from his account. After clicking the specified link it will activated and also verified the user. Without email verification, most of users are does not believe your website or android application. So its mandatory for all applications and websites, one of the major advantage just add the specification.
Create Project
First Create New project and give some name for that, after creating the project need to develop Registration and Login form with attractive interface. Because interface is very important, most of users are fall in attractive interface. In this project i will designed awesome interface look, i hope everyone like that modules.
Additionally in this project, we have another feature. That’s a Social Meme Images feed, when the user register a account, ask image memes to upload from their profile feed and news feed. New users are able to like the meme, comment the meme and share the meme also. This is biggest advantage in this Email Verification android studio (Meme Creation Android Application) project.
Create new java class file under the Home directory, Use name of HomeActivity.java and add the following below code to develop the home page structure.
In this project we need more modules to develop perfect user email login registration verification android studio. Now create one java class for make login code interaction under the directory of Login and the file name is LoginActivity.java. After creating the class just copy the below code,
package com.example.android.memophile.Login; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.example.android.memophile.R; import com.example.android.memophile.Utils.FirebaseMethods; import com.example.android.memophile.Utils.StringManipulation; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.Query; import com.google.firebase.database.ValueEventListener; public class RegisterActivity extends AppCompatActivity { private Context mContext; private String email, username, password; private EditText mEmail, mPassword, mUsername; private TextView loadingPleaseWait; private Button btnRegister; private ProgressBar mProgressBar; //firebase private FirebaseAuth mAuth; private FirebaseAuth.AuthStateListener mAuthListener; private FirebaseMethods firebaseMethods; private FirebaseDatabase mFirebaseDatabase; private DatabaseReference myRef; private String append = ""; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); mContext = RegisterActivity.this; firebaseMethods = new FirebaseMethods(mContext); initWidgets(); setupFirebaseAuth(); init(); } private void init(){ btnRegister.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { email = mEmail.getText().toString(); username = mUsername.getText().toString(); password = mPassword.getText().toString(); if(checkInputs(email, username, password)){ mProgressBar.setVisibility(View.VISIBLE); loadingPleaseWait.setVisibility(View.VISIBLE); firebaseMethods.registerNewEmail(email, password, username); } } }); } private boolean checkInputs(String email, String username, String password){ if(email.equals("") || username.equals("") || password.equals("")){ Toast.makeText(mContext, "All fields must be filled out.", Toast.LENGTH_SHORT).show(); return false; } return true; } /** * Initialize the activity widgets */ private void initWidgets(){ mEmail = (EditText) findViewById(R.id.input_email); mUsername = (EditText) findViewById(R.id.input_username); btnRegister = (Button) findViewById(R.id.btn_register); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); loadingPleaseWait = (TextView) findViewById(R.id.loadingPleaseWait); mPassword = (EditText) findViewById(R.id.input_password); mContext = RegisterActivity.this; mProgressBar.setVisibility(View.GONE); loadingPleaseWait.setVisibility(View.GONE); } private boolean isStringNull(String string){ if(string.equals("")){ return true; } else{ return false; } } /* ------------------------------------ Firebase --------------------------------------------- */ /** * Check is @param username already exists in teh database * @param username */ private void checkIfUsernameExists(final String username) { DatabaseReference reference = FirebaseDatabase.getInstance().getReference(); Query query = reference .child(getString(R.string.dbname_users)) .orderByChild(getString(R.string.field_username)) .equalTo(username); query.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for(DataSnapshot singleSnapshot: dataSnapshot.getChildren()){ if (singleSnapshot.exists()){ append = myRef.push().getKey().substring(2,8); } } String mUsername = ""; mUsername = username + append; //add new user to the database firebaseMethods.addNewUser(email, mUsername, "", "", ""); Toast.makeText(mContext, "Signup successful. Sending verification email.", Toast.LENGTH_SHORT).show(); mAuth.signOut(); } @Override public void onCancelled(DatabaseError databaseError) { } }); } /** * Setup the firebase auth object */ private void setupFirebaseAuth(){ mAuth = FirebaseAuth.getInstance(); mFirebaseDatabase = FirebaseDatabase.getInstance(); myRef = mFirebaseDatabase.getReference(); mAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if (user != null) { // User is signed in myRef.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { checkIfUsernameExists(StringManipulation.condenseUsername(username)); } @Override public void onCancelled(DatabaseError databaseError) { } }); finish(); } else { // User is signed out } // ... } }; } @Override public void onStart() { super.onStart(); mAuth.addAuthStateListener(mAuthListener); } @Override public void onStop() { super.onStop(); if (mAuthListener != null) { mAuth.removeAuthStateListener(mAuthListener); } } }
Activity Layouts
Above we develop just two java classes only, but actually the code is very long and spaces are not enough to explain all java codes. Finally i will give the full source code of User Email Registration verification Android Studio.
Now need to integrate java files with XML layout to improve the layout designs. In this project interfaces are nice look, hope everyone like. Create new xml file, the name of activity_home.xml and add the following code,
Screenshot – Email Registration Verification Android
Here we list the some screenshot images for understanding the project of Email verification Android Studio. After checking output image files you get clear idea like how it’s working on our devices. LAter that you can customize the code as per your own requirements.
Also Read – Android Studio Source Code
Download Source Code
Here you can download the full source code of User Login Registration Email Verification in Android Studio. If you get any issues on login signup verification on your project then just contact us for clarify your issues. We are always online to help our blog readers.