How Can I Fix This? "method Invocation 'isemailverified' May Produce 'java.lang.nullpointerexception'"
I tried to solve it but I can not do anything, I always get the NPE even with the try and catch, I do not know what else to do, please some help, what is the correct way to remove
Solution 1:
Try-catch in this situation will prevent your app from possible crash. That is just a Lint warning.
If you want to remove the warning. First check if the variable user
is null.
if (user == null){
// show errorreturn;
}
// your code
Solution 2:
Before calling isEmailverified check for user. User may be null, so when you try to call a method on null compiler will through null pointer exception.
Try if( user != Null and user.isEmailVerified)
Solution 3:
If you are using mAuth to log your users you can try
if(mAuth.getCurrentUser() != null) {
//do your stuffif(user.isEmailVerified()){ ...}
}
or
if(((mAuth.getCurrentUser() != null)&&(user.isEmailVerified()))) {
//do your stuff
Log.d(TAG, "onComplete: success. email is verified."); ....
}
before you ask for the method isEmailVerified();
so you can guarantee that you have an user connected before requesting information from them
Post a Comment for "How Can I Fix This? "method Invocation 'isemailverified' May Produce 'java.lang.nullpointerexception'""