Login and Registration in Android and Firebase. In this article, we will look at an example to perform Login and Registration in Android using Firebase.
The Android SDK that we are going to use here is the set of development tools to develop applications for the android platform. The database we are using is Firebase which is a cloud-hosted daabase. So, let us start with the development
Following will be the project structure:
Step1: Getting Started With Android Studio
- Create a project with Empty activity.
- In this activity, we will Create the Main Page of our Application
- This page consists of two-button and Each Button linked to other Activity
- Those Two other Activities are SignUp and Login Activity
- findViewById is used to assign View to Object
- On Click, Listener is set to login button when we click on login button following command executed
- We create new intent with the context of this and login class to switch to Login class when startActivity(intent) is executed
MainActivity.class
package com.example.login_reg; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import com.example.login_reg.Sql.DBHelper; public class MainActivity extends AppCompatActivity { Button login,Reg; Toolbar toolbar; DBHelper dbHelper; @Override public void onBackPressed() { MainActivity.this.finish(); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dbHelper = new DBHelper(this); login =(Button) findViewById(R.id.btnLogin); toolbar = (Toolbar) findViewById(R.id.tool_main); login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this,Login.class); startActivity(intent); } }); Reg = findViewById(R.id.btnSignUp); Reg.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this,SignUp.class); startActivity(intent); } }); }
activity_main.xml
- XML consist of Relative layout
- include statement is used to include toolbar to the main activity
- android:id is used to create a unique id for Views and Layout
- Id is used to connect View to variables
- android:background is assigned a theme to Views.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:background="@drawable/background_main" app:layout_goneMarginBottom="10dp"> <include layout="@layout/toolbar" android:id="@+id/tool_main"/> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" tools:ignore="MissingConstraints" > <ImageView android:id="@+id/imageView" android:layout_width="150dp" android:layout_height="150dp" android:layout_marginBottom="10dp" app:tint="#000000" tools:srcCompat="@drawable/logo" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="10dp" android:fontFamily="cursive" android:gravity="center" android:padding="10dp" android:text="Code Bun" android:textSize="60sp" /> <Button android:id="@+id/btnLogin" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:background="@drawable/btn_view" android:fontFamily="sans-serif-black" android:padding="10dp" android:text="Login" android:textColor="#1B1515" android:textSize="18sp" /> <Button android:id="@+id/btnSignUp" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:background="@drawable/btn_view" android:fontFamily="sans-serif-black" android:padding="10dp" android:text="Sign Up" android:textColor="#1B1515" android:textSize="18sp" /> </LinearLayout> </RelativeLayout>
Step 2: Create a New Activity for Login and SignUp page
Right-click on the com.example.<app-name> and create three new empty activity with name Login,SignUp and FinalPage.
- Each of these activities is for a different Task
- class is for login page it consists of the Image view, two edit text, button and a text view that is linked to SingUp activity
- Toast is a popup message
- The intent is used to jump to other activities with the context of this class to Reference Class
- StartActivity is used to jump to another activity
- AlertDialog is a Dialog Box that will display a message
- FirebaseDatabase.getInstance() is used to get Instance of the FirebaseDatabase Class
- FirebaseDatabase.getReference(“User”) is used to refer to User Node in database
- refernce.orderByChild(“userName”).equalTo(userName1); this query will search for userName1 String in database with userName Tag
- addListenerForSingleValueEvent will listen to data change in database for single value
- Snapshot will Give the snapshot of the database.
- SnapShot.child(userName1).child(“pass”).getValue(Long.class) it will return Password of userName that match the userName you Entered.
Login.class
package com.example.login_reg; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.example.login_reg.Sql.DBHelper; package com.example.login_reg; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.example.login_reg.Firebase.DBHelperF; import com.example.login_reg.Sql.DBHelper; 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 Login extends AppCompatActivity { EditText userName, password; Button btnSubmit; TextView createAcc; FirebaseDatabase firebaseDatabase ; DatabaseReference reference; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); userName =findViewById(R.id.text_userName); password=findViewById(R.id.text_pass); btnSubmit = findViewById(R.id.btnSubmit_login); dbHelper = new DBHelper(this); btnSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String userName1 = userName.getText().toString(); long passCheck = Long.parseLong(password.getText().toString()); firebaseDatabase = FirebaseDatabase.getInstance(); reference =firebaseDatabase.getReference("User"); Query query = reference.orderByChild("userName").equalTo(userName1); query.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot snapshot) { if (snapshot.exists()){ Long pass = snapshot.child(userName1).child("pass").getValue(Long.class); if (pass.equals(passCheck)){ Intent intent = new Intent(Login.this,FinalPage.class); intent.putExtra("userName",userName1); startActivity(intent); Toast.makeText(Login.this,"Right Pass ",Toast.LENGTH_SHORT).show(); }else { AlertDialog.Builder builder = new AlertDialog.Builder(Login.this); builder.setCancelable(true); builder.setTitle("Wrong Credential"); builder.setMessage("Wrong Credential"); builder.show();} }else { Toast.makeText(Login.this,"No data exists ",Toast.LENGTH_SHORT).show(); } } @Override public void onCancelled(@NonNull DatabaseError error) { } }); } }); createAcc=findViewById(R.id.createAcc); createAcc.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Login.this,SignUp.class); startActivity(intent); } }); } }
activity_login.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".Login" android:background="@drawable/background_main"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:ignore="MissingConstraints" tools:layout_editor_absoluteX="170dp" tools:layout_editor_absoluteY="74dp" android:gravity="center"> <ImageView android:id="@+id/imageView" android:layout_width="150dp" android:layout_height="150dp" app:tint="#000000" tools:srcCompat="@drawable/logo" android:layout_marginBottom="10dp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="60sp" android:text="Code Bun" android:fontFamily="cursive" android:gravity="center" android:padding="10dp" android:layout_marginBottom="10dp" /> <EditText android:id="@+id/text_email" android:layout_width="match_parent" android:layout_height="60dp" android:background="@drawable/edit_text_box" android:layout_marginBottom="10dp" android:inputType="textEmailAddress" android:hint="Enter Email" android:gravity="center" android:padding="20dp" android:drawableStart="@drawable/ic_mail" /> <EditText android:id="@+id/text_pass" android:layout_width="match_parent" android:layout_height="60dp" android:background="@drawable/edit_text_box" android:layout_marginBottom="10dp" android:inputType="numberPassword" android:hint="Enter Password" android:gravity="center" android:padding="20dp" android:drawableStart="@drawable/ic_lock" /> <Button android:id="@+id/btnSubmit_login" android:layout_width="250dp" android:layout_height="60dp" android:layout_marginBottom="10dp" android:background="@drawable/btn_view" android:fontFamily="sans-serif-black" android:padding="10dp" android:text="Login" android:textColor="#1B1515" android:textSize="18sp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center"> <View android:layout_width="100dp" android:layout_height="2dp" android:background="@android:color/black"/> <TextView android:layout_width="25dp" android:layout_height="25dp" android:textSize="20dp" android:text="Or" android:gravity="center"/> <View android:layout_width="100dp" android:layout_height="2dp" android:background="@android:color/black"/> </LinearLayout> <TextView android:id="@+id/createAcc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Create an Account" android:clickable="true" android:textStyle="bold" android:textSize="20dp" /> </LinearLayout> </RelativeLayout>
SignUp.class
- addValueEventListener will check for changes in database
- checkUser(snapshot,userName1); will return boolean data if userName we enter to signup with already exists
- ds.child(“userName”).getValue(Sting.class); will iterate through userNames in the database and will return false if it already exists
- myRef.child(userName.tostring()).setValue(dbHelperFS); will enter data in data base like and array with name of the array as user name
package com.example.login_reg; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.example.login_reg.Firebase.DBHelperF; import com.example.login_reg.Sql.DBHelper; 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.ValueEventListener; public class SignUp extends AppCompatActivity { EditText number , email,pass,userName; TextView login; DBHelper dbHelper; private DBHelperF dbHelperFS ; private DatabaseReference myRef; private FirebaseDatabase database; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_up); userName=findViewById(R.id.textName); number=findViewById(R.id.textNumber); email=findViewById(R.id.textEmail); pass=findViewById(R.id.textPass); Button signUpAcc = findViewById(R.id.btnSignUpAcc); dbHelper = new DBHelper(this); signUpAcc.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String userName1 = userName.getText().toString(); String number1 = number.getText().toString(); String email1 = email.getText().toString(); String pass1 = pass.getText().toString(); long password = Long.parseLong(pass1) ; database = FirebaseDatabase.getInstance(); myRef = database.getReference("User"); myRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot snapshot) { if (checkUser(snapshot,userName1)){ dbHelperFS = new DBHelperF(userName1,number1,email1,password); myRef.child(userName1.toString()).setValue(dbHelperFS); userName.setText(""); number.setText(""); email.setText(""); pass.setText(""); Toast.makeText(SignUp.this,"Data inserted",Toast.LENGTH_SHORT).show(); Intent i = new Intent(SignUp.this,Login.class); startActivity(i); }else { Toast.makeText(SignUp.this,"User Name Already Exists",Toast.LENGTH_SHORT).show(); } } @Override public void onCancelled(@NonNull DatabaseError error) { } }); } }); login=findViewById(R.id.loginAcc); login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(SignUp.this,Login.class); startActivity(i); } }); } private boolean checkUser(DataSnapshot snapshot,String user) { String user1; for (DataSnapshot ds: snapshot.getChildren()){ user1 =ds.child("userName").getValue(String.class); if (user.equals(user1)){ return false; } } return true; } }
activity_sign_up.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".SignUp" android:background="@drawable/background_main" android:scrollbars="vertical"> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" tools:ignore="MissingConstraints" android:layout_gravity="center" android:gravity="center" android:scrollbars="vertical"> <ImageView android:id="@+id/imageView" android:layout_width="150dp" android:layout_height="150dp" app:tint="#000000" tools:srcCompat="@drawable/logo" android:layout_marginBottom="10dp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="60sp" android:text="Code Bun" android:fontFamily="cursive" android:gravity="center" android:padding="10dp" android:layout_marginBottom="10dp" /> <EditText android:id="@+id/textName" android:layout_width="match_parent" android:layout_height="60dp" android:background="@drawable/edit_text_box" android:layout_marginBottom="10dp" android:inputType="textPersonName" android:hint="Name" android:gravity="center" android:padding="20dp" android:drawableStart="@drawable/ic_name" /> <EditText android:id="@+id/textNumber" android:layout_width="match_parent" android:layout_height="60dp" android:background="@drawable/edit_text_box" android:layout_marginBottom="10dp" android:inputType="number" android:hint="Phone Number" android:gravity="center" android:padding="20dp" android:drawableStart="@drawable/ic_phone" /> <EditText android:id="@+id/textEmail" android:layout_width="match_parent" android:layout_height="60dp" android:background="@drawable/edit_text_box" android:layout_marginBottom="10dp" android:inputType="textEmailAddress" android:hint="Email" android:gravity="center" android:padding="20dp" android:drawableStart="@drawable/ic_mail" /> <EditText android:id="@+id/textPass" android:layout_width="match_parent" android:layout_height="60dp" android:background="@drawable/edit_text_box" android:layout_marginBottom="10dp" android:inputType="numberPassword" android:hint="Password" android:gravity="center" android:padding="20dp" android:drawableStart="@drawable/ic_lock" /> <Button android:id="@+id/btnSignUpAcc" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:background="@drawable/btn_view" android:fontFamily="sans-serif-black" android:padding="10dp" android:text="Sign up" android:textColor="#1B1515" android:textSize="18sp"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center"> <View android:layout_width="100dp" android:layout_height="2dp" android:background="@android:color/black"/> <TextView android:layout_width="25dp" android:layout_height="25dp" android:textSize="20dp" android:text="Or" android:gravity="center"/> <View android:layout_width="100dp" android:layout_height="2dp" android:background="@android:color/black"/> </LinearLayout> <TextView android:id="@+id/loginAcc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login" android:clickable="true" android:textStyle="bold" android:textSize="20dp" /> </LinearLayout> </ScrollView> </RelativeLayout>
FinalPage.class
package com.example.login_reg; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.widget.TextView; public class FinalPage extends AppCompatActivity { TextView text; @Override public void onBackPressed() { FinalPage.this.finish(); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_final_page); text = findViewById(R.id.changeText); Intent intent = getIntent(); String s2 = intent.getStringExtra("userName"); text.setText(s2); } }
activity_final_page.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".FinalPage" android:background="@drawable/background_main"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" > <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:id="@+id/changeText" android:gravity="center" android:editable="false" android:background="@drawable/edit_text_box" android:padding="10dp"/> </LinearLayout> </RelativeLayout>
Step 3 : Setting Up FireBase
- First, we have to connect Firebase to our Android Studio so make sure you Signed in with your Google Id
- Go to https://firebase.google.com sign in and click on Get Started.
- Click on add project.
- Enter your database name and press continue
- Press Continue again
- Select Your Account and Press Create Account
- Click Real-Time database
- Now go to Android Studio
- Goto Tool -> Firebase
- Open Firebase Assistant.
- Click on Realtime Database and then on Get Started
- Click on Connect and then click on add the Realtime Database to your App.
Step 3.1: Setting Up FireBase Helper Class
Right-click on com. example and goto new and then package name it Firebase then create new java class with name DBHelperF
- Create Constructor with values String userName, Number, email, and Long pass
- This Constructor will be used to insert values into the database.
DBHelperF.class
package com.example.login_reg.Firebase; public class DBHelperF { String userName,number,email; long pass; public DBHelperF(String userName, String number, String email, long pass) { this.userName = userName; this.number = number; this.email = email; this.pass = pass; } public String getUserName() { return userName; } public String getNumber() { return number; } public String getEmail() { return email; } public long getPass() { return pass; } }
Step 4: Creating Resource Files
Go to app -> res -> drawable and create these files.
Background_main.xml
- gradient is used to mix colors
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <gradient android:angle="90" android:startColor="#A443E9" android:endColor="#38f9d7" android:type="linear"/> </shape> </item> </selector>
Btn_view.xml
- Shape tag is used to give shape to view
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="true"> <shape android:shape="rectangle"> <corners android:radius="10dp"/> <gradient android:startColor="#A443E9" android:endColor="#38f9d7" android:type="linear"/> </shape> </item> </selector>
Edit_text_box.xml
- corners tag is used to curve the view
- if it is a rectangle giving it 10dp it will be more like ovel shape.
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="true" android:state_focused="true"> <shape android:shape="rectangle"> <gradient android:startColor="#A443E9" android:endColor="#38f9d7" android:type="linear"/> <corners android:radius="10dp"/> </shape> </item> </selector>
ic_lock.xml
- Right-Click on Drawable select vector asset
- Search for Lock and select and rename it to ic_lock.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> <path android:fillColor="@android:color/white" android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0, -1.1 -0.9,-2 -2,-2zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM15.1,8L8.9,8L8.9,6c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2z"/> </vector>
Ic_mail.xml
- Right-Click on Drawable select vector asset
- Search for mail and select and rename it to ic_mail.xml.
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> <path android:fillColor="@android:color/white" android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/> </vector>
Ic_name.xml
- Right-Click on Drawable select vector asset
- Search for the name and select and rename it to ic_name.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> <path android:fillColor="@android:color/white" android:pathData="M12,5.9c1.16,0 2.1,0.94 2.1,2.1s-0.94,2.1 -2.1,2.1S9.9,9.16 9.9,8s0.94,-2.1 2.1,-2.1m0,9c2.97, 0 6.1,1.46 6.1,2.1v1.1L5.9,18.1L5.9,17c0,-0.64 3.13,-2.1 6.1,-2.1M12,4C9.79,4 8,5.79 8,8s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,13c-2.67,0 -8,1.34 -8,4v3h16v-3c0,-2.66 -5.33,-4 -8,-4z"/> </vector>
Ic_phone.xml
- Right-Click on Drawable select vector asset
- Search for phone and select and rename it to ic_phone.xml.
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" android:tint="?attr/colorControlNormal"> <path android:fillColor="@android:color/white" android:pathData="M6.62,10.79c1.44,2.83 3.76,5.14 6.59,6.59l2.2,-2.2c0.27,-0.27 0.67,-0.36 1.02,-0.24 1.12, 0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1V20c0,0.55 -0.45,1 -1,1 -9.39,0 -17,-7.61 -17,-17 0,-0.55 0.45, -1 1,-1h3.5c0.55,0 1,0.45 1,1 0,1.25 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z"/> </vector>
Step 5: Creating Custom Toolbar
- Goto app -> res ->Layout
- Create a new resource file
- It is a custom toolbar
- we assign a text view to the toolbar
- And attach this tool bar to the Main activity.
<?xml version="1.0" encoding="utf-8"?> <androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/background_main" android:elevation="4dp" android:gravity="center" > <TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:id="@+id/SetTitle_main" android:text="Code Bun" android:textSize="25dp" android:layout_gravity="center" android:gravity="center" android:foregroundGravity="center" android:textStyle="bold" /> </androidx.appcompat.widget.Toolbar>
In this way, we create a login and registration in Android using the Firebase database.
Android practice tasks
https://codebun.com/login-and-registration-in-android-and-sqlite/
https://codebun.com/dynamic-and-static-dropdown-menuspinner-in-android/
https://codebun.com/crud-operation-using-sqlite-in-android/
https://codebun.com/crud-operation-in-android-using-firebase-database/
https://codebun.com/how-to-get-data-from-api-in-android/
https://codebun.com/how-to-create-custom-alert-dialog-in-android/
https://codebun.com/search-and-sort-records-in-android-with-recycler-view/
https://codebun.com/create-a-custom-notification-with-custom-message-in-android/