public class AuthAppRepository { private Application application; private FirebaseAuth firebaseAuth; private MutableLiveData<FirebaseUser> userLiveData; private MutableLiveData<Boolean> loggedOutLiveData; public void register(String email, String password) { firebaseAuth.createUserWithEmailAndPassword(email, password) .addOnCompleteListener(application.getMainExecutor(), new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { userLiveData.postValue(firebaseAuth.getCurrentUser()); } else { Toast.makeText(application.getApplicationContext(), "Registration Failure: " + task.getException().getMessage(), Toast.LENGTH_SHORT).show(); } } }); } }