[英]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.