如何在Android上通过电子邮件和密码使用Firebase登录 [英] How to use firebase login with email and password on Android

查看:120
本文介绍了如何在Android上通过电子邮件和密码使用Firebase登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试关注Firebase网站进行教程时( https://www.firebase.com/docs/web/guide/login/password.html )在android studio上开发简单登录时,我遇到了错误,出现了红色的摆动线.

When I tried to follow the Firebase website for tutorial (https://www.firebase.com/docs/web/guide/login/password.html) on developing a simple login on android studio, I faced error, with red wiggly lines.

有人可以帮助我还是建议一个好的地方,以逐步学习如何使用Firebase创建简单登录的教程. Android的Firebase登录资源在网上非常有限.如果有人可以帮助我,那将是很棒的.

Could someone help me or suggest a good place to learn about step by step tutorial on how to create a simple login using firebase. Resources on firebase login for android are very limited online. Would be great if someone could help me .

这是从firebase网站复制的用于登录的代码,当我将其粘贴到我的代码中时,电子邮件密码功能错误UserData等出现红色错误.

This is the code copied from firebase website for login, when I paste it into my code I have red error on email password function error UserData etc etc.

   mRef.createUser({
            email    : "bobtony@firebase.com",
            password : "correcthorsebatterystaple"
    }, function(error, userData) {
        if (error) {
            console.log("Error creating user:", error);
        } else {
            console.log("Successfully created user account with uid:", userData.uid);
        }
    });

推荐答案

使用具有用户名和密码的firebase登录

to login using firebase with username and password

 auth.signInWithEmailAndPassword(
    edt_username.text.toString().trim(),
    edt_password.text.toString().trim()
)
    .addOnCompleteListener(this) { task ->
        if (task.isSuccessful) {
            // Sign in success, update UI with the signed-in user's information
            Log.d("Status", "signInWithEmail:success")
            val user = auth.currentUser

            showAlert("User Logged-in Successfully ","Welcome :"+user)

        } else {
            // If sign in fails, display a message to the user.
            Log.w("Status", "signInWithEmail:failure", task.exception)
            showAlert("User not found ","Register")

        }

    }

http://www.androidcoding.in/2020/06/02/android-firebase-login-tutorial/

这篇关于如何在Android上通过电子邮件和密码使用Firebase登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆