简体   繁体   中英

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM