Skip to content

Instantly share code, notes, and snippets.

@laxyapahuja
Created May 20, 2019 08:42
Show Gist options
  • Save laxyapahuja/dba31a662e9c22e9372b50013a1f3cd0 to your computer and use it in GitHub Desktop.
Save laxyapahuja/dba31a662e9c22e9372b50013a1f3cd0 to your computer and use it in GitHub Desktop.
Signing up accounts using Firebase
public void signUp(View view) {
EditText loginet=findViewById(R.id.email);
EditText passwordet=findViewById(R.id.password);
String email=loginet.getText().toString();
String password=passwordet.getText().toString();
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
FirebaseUser user = mAuth.getCurrentUser();
Toast.makeText(getApplicationContext(),"Sign up successful.",Toast.LENGTH_LONG).show();
startActivity(new Intent(MainActivity.this,AddTask.class));
} else {
// If sign in fails, display a message to the user.
Toast.makeText(getApplicationContext(),"Sign up failed.",Toast.LENGTH_LONG).show();
}
// ...
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment