[英]Null pointer exception on getEmail() in firebase
I want to get email address of a user from firebase.This email address is uses to check the user is authenticated with email or phone number. 我想从Firebase获取用户的电子邮件地址。此电子邮件地址用于检查用户是否已通过电子邮件或电话号码进行身份验证。
user=mAuth.getCurrentUser ;
if(user.getEmail!=null){
......do something
}
else{
......do something
}
But,My problem is when i want to start this activity that closes and raise null pointer exception.How can i fix this problem.? 但是,我的问题是,当我想启动关闭并引发空指针异常的活动时,如何解决此问题。
If no user is signed in, getCurrentUser returns null: ....... 如果没有用户登录,则getCurrentUser返回null:.......
getCurrentUser might also return null because the auth object has not finished initializing. 由于auth对象尚未完成初始化,因此getCurrentUser也可能返回null。
May be because of the reasons above your user object is null and throws NullPointerException. 可能由于上述原因,您的用户对象为null并引发NullPointerException。 You should attach an AuthStateListener to get the currently signed in user. 您应该附加AuthStateListener来获取当前登录的用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.