简体   繁体   English

在 Android Studio 中,如何检查用户是匿名登录还是使用 email 或 google 登录?

[英]In Android Studio, how to check if user logged in anonymously or with email, or google sign in?

I have an app.我有一个应用程序。 On startup, it is logging in anonymously, automatically.启动时,它会自动匿名登录。 Then you can sign in for real if you want.然后,您可以根据需要进行真实登录。 There is a button, that i want to make useable only for "real logged-in" users.有一个按钮,我想让它只对“真正登录”的用户可用。 I tried this code but this is true for anonymously signed-in users too:我试过这段代码,但匿名登录用户也是如此:

user = FirebaseAuth.getInstance().getCurrentUser();     
                if(user != null){
                //can use button
                }else{
                    // "please sign in!"
                }

You can see whether the user is anonymously logged in by checking its isAnonymous() method .您可以通过检查其isAnonymous()方法来查看用户是否匿名登录。

If you want to check for specific non-anonymous providers, you can check the providerId in the providerData as shown here: Detect Firebase Auth Provider for Loged in User如果要检查特定的非匿名提供程序,可以检查providerId中的providerData ,如下所示: Detect Firebase Auth Provider for Loged in User

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

相关问题 保持用户登录 Android Studio - Keeping the user logged in in Android Studio 如何使用java在android studio中使用GoogleSignInOptions检查用户是否是新用户? - How to check if user is new using GoogleSignInOptions in android studio using java? 在 firebase 中检查用户是否为新用户的最佳方法是什么 谷歌使用 flutter 登录 - What is the best way to check if the user is new in firebase google sign in with flutter Firebase 使用email登录后google登录报错:密码无效或用户没有密码 - Firebase Sign-in with email after google sign-in has error : The password is invalid or the user does not have a password Google Firebase 注销并忘记 Android 应用中的用户 - Google Firebase sign out and forget user in Android app 如何检查用户是否已登录,如果已登录则显示其他屏幕? - How to check if the user is logged in, if so show other screen? Firebase:如何让 Android 用户保持登录状态? - Firebase: How to keep an Android user logged in? 如果用户在 flutter 中使用 email 或 gmail 登录,如何获取快照 - How to get snapShot if user have sign in with email or gmail in flutter email未验证时如何注销用户,Firebase Auth - How to sign out the user when the email is not verified, Firebase Auth Firebase Auth 如何检查用户是否已注册或登录? - Firebase Auth how to check if the user is Signed Up or Logged In?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM