What lines of code can in include in my class so as to have a validation technique for both email and password?

What lines of code can in include in my class so as to have a validation technique for both email and password?

I have written the following lines of code and i need to include an error validation check in it for both Email and Password. The output on the screen upon a wrong mail/password entry should be in the form of a Toast.makeText() format. So here is the code below

I have written the following lines of code and i need to include an error validation check in it for both Email and Password. The output on the screen upon a wrong mail/password entry should be in the form of a Toast.makeText() format. So here is the code below

public class MainActivity extends AppCompatActivity implements View.OnClickListener { public void clickRegister(View view) {

    startActivity(new Intent(MainActivity.this, RegisterActivity.class));

}

private Button buttonSignin;
private EditText emailAdd;
private EditText passAdd;
private FirebaseAuth firebaseAuth;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    firebaseAuth=FirebaseAuth.getInstance();
    if(firebaseAuth.getCurrentUser()!=null){
        //Remote control activity
        finish();
        startActivity(new Intent(getApplicationContext(),RemoteControl.class));
    }
    buttonSignin = (Button) findViewById(R.id.logIn);
    emailAdd = (EditText) findViewById(R.id.emailAddress);
    passAdd = (EditText) findViewById(R.id.passWord);

    buttonSignin.setOnClickListener(this);


}

private void userLogin(){ String email=emailAdd.getText().toString().trim(); String password=passAdd.getText().toString().trim(); if(TextUtils.isEmpty(email)){ //Email is empty! Toast.makeText(this,"Please Enter Email",Toast.LENGTH_SHORT).show(); //Stop function from executing further return; }

if (TextUtils.isEmpty(password))
{
    //Password is empty
    Toast.makeText(this,"Please Enter Password",Toast.LENGTH_SHORT).show();
    return;
}


firebaseAuth.signInWithEmailAndPassword(email,password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
    @Override
    public void onComplete(@NonNull Task<AuthResult> task) {
        if(task.isSuccessful()){
            //start profile activity
            finish();
            startActivity(new Intent(getApplicationContext(),RemoteControl.class));
        }
    }
});

} @Override public void onClick(View view) { if(view==buttonSignin) { userLogin(); }

}

}

I expect an output of "Incorrect Email" and "Incorrect password" for each line of bad entry in the form of a Toast.maketext()

java android

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Top Android Projects with Source Code

Android projects with source code - Work on real-time android projects. We’ll start project ideas from beginners level and later move to advance projects.

How to Install OpenJDK 11 on CentOS 8

What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).

Building Dark Mode Theme in Android

Hello World, today we are going to see how we can implement a dark theme or night mode in our android application. This tutorial is going to be very simple and easy to understand. The dark theme is attractive to users and it is comfortable for low light conditions.

Top 130 Android Interview Questions - Crack Technical Interview Now!

Top Android Interview Questions & Answers from Beginner to Advanced level. Get ready to crack your next android interview with these android interview questions

Android Menu - Steps to implement Menu in Android - DataFlair

Implement Android Menu in your application - Provide functionality to your application and make it user friendly. Also, Learn its types and implementation.