Yasir Ali
Yasir Ali

Reputation: 155

Firebase getCurrentUser method explanation required

Can any one tell me that what does get Current User do?

private ProgressDialog progressDialog;
private FirebaseAuth firebaseAuth;
progressDialog = new ProgressDialog(this);
    firebaseAuth = FirebaseAuth.getInstance();
    if (firebaseAuth.getCurrentUser() != null){
        //start profile activity
        finish();
        startActivity(new Intent(getApplicationContext(),Profile.class));
    }

I am confused on which user get Current User pick?

Upvotes: 0

Views: 1256

Answers (2)

Akshay
Akshay

Reputation: 1161

firebaseAuth.getCurrentUser() is used get a FirebaseUser object, which contains information about the signed-in user. If it returns null the user has not signed in else it will be redirected to Profile.class...(In your above code)

Upvotes: 2

angelos_lex
angelos_lex

Reputation: 1661

FirebaseAuth.getInstance().getCurrentUser() returns the currently logged in user in firebase. The user which whith whom the credentials you made the login from your android emulator. If a user isn't signed in, getCurrentUser returns null.

Upvotes: 2

Related Questions