Java 如何从Firebase数据库获取密码并与edittext匹配?
我是android studio和java的新手 我在firebasedatabase代码上创建了它,并希望按照如下所示对其进行编码Java 如何从Firebase数据库获取密码并与edittext匹配?,java,android,firebase,Java,Android,Firebase,我是android studio和java的新手 我在firebasedatabase代码上创建了它,并希望按照如下所示对其进行编码 Class aclass { String codeX= someedittext.toString(); String codeY= coderetrievedfromfirebase.toString(); if (codex=codey){do something}; } 提前感谢您可以使用FirebaseAuth使用以下代码验证您的电子邮件和密码:- p
Class aclass {
String codeX= someedittext.toString();
String codeY= coderetrievedfromfirebase.toString();
if (codex=codey){do something};
}
提前感谢您可以使用FirebaseAuth使用以下代码验证您的电子邮件和密码:-
private FirebaseAuth mAuth = FirebaseAuth.getInstance();
mAuth.signInWithEmailAndPassword(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
Log.d(TAG, "signInWithEmail:success");
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithEmail:failure", task.getException());
Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
updateUI(null);
}
// ...
}
});
有关更多信息,您可以通过使用
.equals()
来比较字符串
。是的,但问题是我不知道如何从Firebase检索该字符串。您阅读了吗?
private void updateUI(FirebaseUser user){
if (user != null) {
// Name, email address, and profile photo Url
String name = user.getDisplayName();
String email = user.getEmail();
Uri photoUrl = user.getPhotoUrl();
// Check if user's email is verified
boolean emailVerified = user.isEmailVerified();
// The user's ID, unique to the Firebase project. Do NOT use this value to
// authenticate with your backend server, if you have one. Use
// FirebaseUser.getIdToken() instead.
String uid = user.getUid();
}
}