Starting to write an application using Android Studio, I ran into a problem regarding the firebase login command. The application is connected to firebase and the user list contains the provided strings for 'mail' and 'pw'. The method 'login()' should return one of both messages, but nothing is happening (not even an error message in the log). The code is given below:
public class MainActivity extends AppCompatActivity {
FirebaseAuth firebaseAuth;
Dialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseApp.initializeApp(this);
firebaseAuth = FirebaseAuth.getInstance();
if (firebaseAuth.getCurrentUser() == null) {
logIn();
}
}
private void logIn() {
String mail = "example@gmail.com";
String pw = "password";
firebaseAuth.signInWithEmailAndPassword(mail, pw)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(getApplicationContext(), "Login successful", Toast.LENGTH_LONG).show();
} else {
Log.w("Sign in error: ", task.getException());
Toast.makeText(getApplicationContext(), "Login unsuccessful", Toast.LENGTH_LONG).show();
}
}
});
}
}