我如何使用电子邮件身份验证的详细信息登录Firebase

时间:2018-11-07 15:55:47

标签: android firebase firebase-realtime-database firebase-authentication

我如何使用Firebase电子邮件身份验证的详细信息登录,而不是使用我添加的电子邮件和密码登录我。.

   private void loginToFirebase() {
    String email = getString(R.string.firebase_email);
    String password = getString(R.string.firebase_password);
    // Authenticate with Firebase and subscribe to updates
    FirebaseAuth.getInstance().signInWithEmailAndPassword(
            email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(Task<AuthResult> task) {
            if (task.isSuccessful()) {
                subscribeToUpdates();
                Log.d(TAG, "firebase auth success");
            } else {
                Log.d(TAG, "firebase auth failed");
            }
        }
    });
} 

1 个答案:

答案 0 :(得分:1)

就像Firebase文档中所说的那样:

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
// User is signed in
} else {
// No user is signed in
}

Here is the Firebase documentation