I was trying to set Toast
, to show is registratiion was succesful of failed. But couldn't make it resolve the context
. There is the code:
private void RegisterAccount() {
String username = RegisterUsername.getText().toString();
String mail = RegisterMail.getText().toString();
String password = RegisterPassword.getText().toString();
mAuth.createUserWithEmailAndPassword(mail, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
User user = new User(username, mail);
FirebaseDatabase.getInstance().getReference("Users")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(RegisterAccount.this, "Success", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(RegisterAccount.this, "Failed", Toast.LENGTH_LONG).show();
}
}
});
}
else {
Toast.makeText(RegisterAccount.this, "Failed", Toast.LENGTH_LONG).show();
}
}
});
}
Error: Cannot resolve symbol 'RegisterAccount'
for all 3 Toast
-s
I tried Toast.makeText(RegisterAccount(), "Failed", Toast.LENGTH_LONG).show();
, RegisterAccount()
instead of RegisterAccount.this
and got error: Cannot resolve method 'makeText(void, java.lang.String, int)'
.