Guest User

Untitled

a guest
Mar 12th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. @Override
  2. protected void onCreate(Bundle savedInstanceState) {
  3. super.onCreate(savedInstanceState);
  4. setContentView(R.layout.activity_login);
  5.  
  6. mAuth = FirebaseAuth.getInstance();
  7. username = (EditText) (findViewById(R.id.username));
  8. password = (EditText) (findViewById(R.id.password));
  9. signIn = (Button) (findViewById(R.id.signIn));
  10. register = (Button) (findViewById(R.id.register));
  11. }
  12.  
  13. private void registerUser()
  14. {
  15. loginUsernameString = username.getText().toString();
  16. loginPasswordString = password.getText().toString();
  17.  
  18. mAuth.createUserWithEmailAndPassword(loginUsernameString, loginPasswordString)
  19. .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
  20. @Override
  21. public void onComplete(@NonNull Task<AuthResult> task) {
  22. Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
  23.  
  24. // If sign in fails, display a message to the user. If sign in succeeds
  25. // the auth state listener will be notified and logic to handle the
  26. // signed in user can be handled in the listener.
  27. if (!task.isSuccessful()) {
  28. Toast.makeText(LoginActivity.this, "Failed",
  29. Toast.LENGTH_SHORT).show();
  30. }
  31.  
  32. // ...
  33. }
  34. });
  35. }
  36. public void onClick(View view)
  37. {
  38. if (view == signIn)
  39. registerUser();
  40. }
Add Comment
Please, Sign In to add comment