Firebaseauth.getinstance() Always Return Null
I know I can see so many questions on this topic on stackoverflow and I have tried almost all of them and haven't worked yet so this is my only option to post a new question. My pr
Solution 1:
Finally found the answer, it was because of the
tools:node="replace"
in the manifest. Just remove it and it will work fine.
Solution 2:
fix this method:
@OverridepublicvoidonStart() {
super.onStart();
FirebaseUserfirebaseUser= mAuth.getCurrentUser();//here u must have //instance first then use the methodif(firebaseUser != null){
Toast.makeText(this.getContext(), "Already Sign in ",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this.getContext(), "mAuth Still null ",
Toast.LENGTH_SHORT).show();
}
}
code below will work correct for u
@OverridepublicvoidonStart() {
super.onStart();
FirebaseApp.initializeApp(this.getContext());
mAuth = FirebaseAuth.getInstance();
FirebaseUserfirebaseUser= getInstance(); //first try without this line
firebaseUser = mAuth.getCurrentUser();
if(firebaseUser != null){
Toast.makeText(this.getContext(), "Already Sign in ",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this.getContext(), "mAuth Still null ",
Toast.LENGTH_SHORT).show();
}
}
Post a Comment for "Firebaseauth.getinstance() Always Return Null"