-
-
Save boomboompower/edf101c2cc877112892eb57461835311 to your computer and use it in GitHub Desktop.
Create Account and SignIn using Firebase Authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void createAccount(final String email, final String password) { | |
mAuth.createUserWithEmailAndPassword(email, password) | |
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { | |
@Override | |
public void onComplete(@NonNull Task<AuthResult> task) { | |
if (task.isSuccessful()) { | |
Intent i = new Intent(LoginActivity.this, MainActivity.class); | |
startActivity(i); | |
} else { | |
Toast.makeText(LoginActivity.this, "Authentication failed.", | |
Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
} | |
private void signIn(String email, String password) { | |
mAuth.signInWithEmailAndPassword(email, password) | |
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { | |
@Override | |
public void onComplete(@NonNull Task<AuthResult> task) { | |
if (task.isSuccessful()) { | |
Intent i = new Intent(LoginActivity.this, MainActivity.class); | |
startActivity(i); | |
} else { | |
Toast.makeText(LoginActivity.this, "Authentication Failed", | |
Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment