Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. public void signUpUser(View view){
  2.  
  3. EditText mailEditText = (EditText) findViewById(R.id.editText);
  4. EditText pwdEditTet = (EditText) findViewById(R.id.editText2);
  5.  
  6.  
  7. String email = mailEditText.getText().toString();
  8. String password = pwdEditTet.getText().toString();
  9.  
  10. Log.d("Info",email);
  11. Log.d("Info",password);
  12.  
  13. mAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
  14. @Override
  15. public void onComplete(@NonNull Task<AuthResult> task) {
  16. try {
  17. AuthResult result = task.getResult();
  18.  
  19. Log.d("Sign up", "createUserWithEmail:onComplete:" + task.isSuccessful());
  20.  
  21.  
  22. // If sign in fails, display a message to the user. If sign in succeeds
  23. // the auth state listener will be notified and logic to handle the
  24. // signed in user can be handled in the listener.
  25. if (!task.isSuccessful()) {
  26. Toast.makeText(MainActivity.this, R.string.auth_failed,
  27. Toast.LENGTH_SHORT).show();
  28. }else{
  29. Log.d("Sign up", "Sending verification email");
  30. // Sending the verification email
  31. //FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
  32.  
  33. mAuth.getCurrentUser().sendEmailVerification()
  34. .addOnCompleteListener(new OnCompleteListener<Void>() {
  35. @Override
  36. public void onComplete(@NonNull Task<Void> task) {
  37. if (task.isSuccessful()) {
  38. Log.d("Email Sent", "Verification Email sent.");
  39. }else{
  40. Log.d("Email Sent",task.getException().getLocalizedMessage());
  41. }
  42. }
  43. });
  44. }
  45. } catch (Exception e){
  46. Toast.makeText(MainActivity.this,R.string.user_exist,Toast.LENGTH_SHORT).show();
  47. Log.e("Exception",e.getLocalizedMessage());
  48. }
  49. }
  50. });
  51. }
  52.  
  53. 10-11 10:10:50.372 31518-31518/au.com.savedme D/Sign up: Sending verification email
  54. 10-11 10:10:51.438 31518-31518/au.com.savedme D/Email Sent: An internal error has occurred. [ USER_NOT_FOUND ]
  55. 10-11 10:11:00.429 31518-31538/au.com.savedme W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement