Skip to content

Instantly share code, notes, and snippets.

@alvareztech
Created March 14, 2016 20:41
Show Gist options
  • Save alvareztech/c47f49cba34ffbf31cca to your computer and use it in GitHub Desktop.
Save alvareztech/c47f49cba34ffbf31cca to your computer and use it in GitHub Desktop.
Sample login Firebase Android.
public class LoginActivity extends AppCompatActivity {
private Firebase ref;
private Firebase.AuthResultHandler authResultHandler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
authResultHandler = new Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
System.out.println("authData:" + authData.getUid());
// login ok, open new Activity
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
System.out.println("onAuthenticationError:" + firebaseError.getCode() + ":" + firebaseError.getMessage());
}
};
}
public void login(View view) {
email = emailEditText.getText().toString();
pass = passEditText.getText().toString();
ref.authWithPassword(email, pass, authResultHandler);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment