Created
March 14, 2016 20:41
-
-
Save alvareztech/c47f49cba34ffbf31cca to your computer and use it in GitHub Desktop.
Sample login Firebase Android.
This file contains hidden or 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
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