java - getCurrentUser() functions error -


firebaseuser currentfirebaseuser = firebaseauth.getinstance().getcurrentuser(); currentfirebaseuser.getdisplayname(); 

this code works functions when auth google when auth facebook nullpointerexception. check user using code

 if (firebaseauth.getinstance().getcurrentuser() == null) {         gotologinscreen();     }     else{         string uid = firebaseauth.getinstance().getcurrentuser().getuid();     } 

the documentation getcurrentuser() says will, in fact, return null if there no current user (there no 1 logged in). should expect case possibility.

if want know possible if there user logged in, should instead use authstatelistener check login event calling getcurrentuser() in onauthstatechanged() see if returns non-null.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -