Guest User

Untitled

a guest
Oct 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. mAuth.createUserWithEmailAndPassword(email,password)
  2. .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
  3. @Override
  4. public void onComplete(@NonNull Task<AuthResult> task) {
  5.  
  6. if (task.isSuccessful())
  7. {
  8. user user=new user(
  9. nameOfUser,
  10. email,
  11. phNo
  12. );
  13. //Toast.makeText(Register_User.this, "Working", Toast.LENGTH_SHORT).show();
  14.  
  15. mData.getReference("Users")
  16. .child(Objects.requireNonNull(FirebaseAuth.getInstance().getCurrentUser()).getUid())
  17. .push().setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
  18.  
  19. @Override
  20. public void onComplete(@NonNull Task<Void> task) {
  21. progressBar.setVisibility(View.GONE);
  22.  
  23. Toast.makeText(Register_User.this, "Upto here", Toast.LENGTH_LONG).show();
  24. if (task.isSuccessful()) {
  25. Toast.makeText(Register_User.this, "Successfully Registered", Toast.LENGTH_SHORT).show();
  26. } else {
  27. Toast.makeText(Register_User.this, "Failed to Registered", Toast.LENGTH_SHORT).show();
  28. }
  29. }
  30. });
  31. }
  32. else if (task.getException() instanceof FirebaseAuthUserCollisionException) {
  33. progressBar.setVisibility(View.GONE);
  34. Toast.makeText(getApplicationContext(), "You are already registered", Toast.LENGTH_SHORT).show();
  35. }
  36. }
  37. });
Add Comment
Please, Sign In to add comment