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
Post a Comment