I am trying to make an app with a login function and I want to keep the user logged in. I'm using Firebase auth and android studio.
This is what I tried:
auth.signInWithEmailAndPassword(txt_email, txt_password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()){
Intent intent = new Intent(login.this, sendForm.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
else {
Toast.makeText(login.this, "cant sing in", Toast.LENGTH_SHORT).show();
}
}
});