Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mAuth.createUserWithEmailAndPassword(email,password)
- .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
- @Override
- public void onComplete(@NonNull Task<AuthResult> task) {
- if (task.isSuccessful())
- {
- user user=new user(
- nameOfUser,
- email,
- phNo
- );
- //Toast.makeText(Register_User.this, "Working", Toast.LENGTH_SHORT).show();
- mData.getReference("Users")
- .child(Objects.requireNonNull(FirebaseAuth.getInstance().getCurrentUser()).getUid())
- .push().setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
- @Override
- public void onComplete(@NonNull Task<Void> task) {
- progressBar.setVisibility(View.GONE);
- Toast.makeText(Register_User.this, "Upto here", Toast.LENGTH_LONG).show();
- if (task.isSuccessful()) {
- Toast.makeText(Register_User.this, "Successfully Registered", Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(Register_User.this, "Failed to Registered", Toast.LENGTH_SHORT).show();
- }
- }
- });
- }
- else if (task.getException() instanceof FirebaseAuthUserCollisionException) {
- progressBar.setVisibility(View.GONE);
- Toast.makeText(getApplicationContext(), "You are already registered", Toast.LENGTH_SHORT).show();
- }
- }
- });
Add Comment
Please, Sign In to add comment