I can't move to the LoginPageActivity.I think the problem is in my 'Intent' statement. Maybe, I gave wrong 'context'. Everything looks good. But application is crushing. I couldn't find the problem. Can you help me? What shall I give as a context in the MainActivity and ELSE statement?
I think the problem is Intent in Helper class.
I have an IF condition like this:
public void createNewUser(final Context context, String email, String password){
firebaseAuth = FirebaseAuth.getInstance();
firebaseAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener((Activity) context, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
ShortCut.displayMessageToast(context, "invalid info");
}else {
ShortCut.displayMessageToast(context, "Account created");
Intent loginIntent = new Intent(context, LoginPageActivity.class);
context.startActivity(loginIntent);
}
}
});
}
When I am trying to create a new account my else condition is works. But, why can't I move to LoginPageActivity?
And, I call from here in MainActivity:
@OnClick(R.id.createBtn)
void createButonClicked(){
String email = mEmail.getText().toString();
String password = mPassword.getText().toString();
String clientName = mClientName.getText().toString();
String clientSurname = mClientSurname.getText().toString();
String clientCity = mClientCity.getText().toString();
String clientPhone = mClientPhone.getText().toString();
if (TextUtils.isEmpty(email)
|| TextUtils.isEmpty(password)
|| TextUtils.isEmpty(clientName)
|| TextUtils.isEmpty(clientSurname)
|| TextUtils.isEmpty(clientCity)
|| TextUtils.isEmpty(clientPhone))
{
ShortCut.displayMessageToast(this, "You should fill empty fields!");
}else {
firebaseApplication = new FirebaseApplication();
firebaseApplication.createNewUser(this, email, password);
ShortCut.displayMessageToast(this, "just for a debug");
}
}