简体   繁体   English

如何从 Firebase 数据库中获取密码并与 edittext 匹配?

[英]How can I get password from Firebase database and match with edittext?

I am new in android studio and java as well我是 android 工作室和 java 的新手

I created on firebasedatabase codes and I want to code it as shown below我在 firebasedatabase 代码上创建,我想按如下所示对其进行编码

Class aclass {
String codeX= someedittext.toString();
String codeY= coderetrievedfromfirebase.toString();
if (codex=codey){do something};
}

Thanks in advance提前致谢

You may use FirebaseAuth to authenticate your email and password by using below code:-您可以使用FirebaseAuth使用以下代码验证您的 email 和密码:-

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);
                    }

                    // ...
                }
            });

updateUI:更新界面:

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();
}
}

For more information you may go through Google Firebase Authentication有关更多信息,您可以通过Google Firebase 身份验证 go

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用户登录时如何从 Firebase 数据库中填充编辑文本 - How can i fill an edittext from the Firebase database when the user logs in 我如何从该Firebase JSON数据库获取所有图像 - how can i get all Images from this firebase JSON database 我如何不重复地从firebase数据库中获取数据 - how I can get data from the firebase database without repeat 如何在EditText密码中添加填充? - How I can add padding in EditText password? 我怎样才能使列表视图中的edittext数据进入数据库? - How can i make data from an edittext in a listview go into the database? 如何在连接到数据库之前在运行时获取数据库密码 - how can i get database password at runtime before connecting to the database 我如何从EditText获取值并将其转换为int类型 - How can i get value from EditText and convert it to int type 如何从另一个 XML 文件中获取 EditText 的文本? - How can i get the text of an EditText from another XML file? 如何检查用户是否已在firebase身份验证和firebase实时数据库中的数据之间注册和匹配数据? - How can I check user had registered and match data between data on firebase authentication and firebase Realtime Database? 为什么我无法从 Firebase 实时数据库中检索用户名和密码 - Why i can't retrieve username and password from Firebase realtime database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM