Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_login);
- mAuth = FirebaseAuth.getInstance();
- username = (EditText) (findViewById(R.id.username));
- password = (EditText) (findViewById(R.id.password));
- signIn = (Button) (findViewById(R.id.signIn));
- register = (Button) (findViewById(R.id.register));
- }
- private void registerUser()
- {
- loginUsernameString = username.getText().toString();
- loginPasswordString = password.getText().toString();
- mAuth.createUserWithEmailAndPassword(loginUsernameString, loginPasswordString)
- .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
- @Override
- public void onComplete(@NonNull Task<AuthResult> task) {
- Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
- // If sign in fails, display a message to the user. If sign in succeeds
- // the auth state listener will be notified and logic to handle the
- // signed in user can be handled in the listener.
- if (!task.isSuccessful()) {
- Toast.makeText(LoginActivity.this, "Failed",
- Toast.LENGTH_SHORT).show();
- }
- // ...
- }
- });
- }
- public void onClick(View view)
- {
- if (view == signIn)
- registerUser();
- }
Add Comment
Please, Sign In to add comment