简体   繁体   English

Firebase中的getEmail()上的空指针异常

[英]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.? 但是,我的问题是,当我想启动关闭并引发空指针异常的活动时,如何解决此问题。

From the docs : 文档

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.

相关问题 在获取Firebase数据时出现空指针异常 - Null pointer exception while fetching firebase data 如何修复 Null 指针异常 Firebase Auth - How to fix Null pointer exception Firebase Auth Firebase Firestore 为存在的键提供空指针异常 - Firebase Firestore gives null pointer exception for a key which exists Firebase firestore 数据检索引发 null 指针异常? - Firebase firestore data retrieval throws null pointer exception? firebase.auth.FirebaseUser.linkWithCredential 抛出空指针异常 - firebase.auth.FirebaseUser.linkWithCredential throws null pointer exception 如何在Firebase身份验证中修复空指针异常? - How can i fix null pointer exception in Firebase Authentication? 使用 Firebase 消息实现通知时出现空指针异常 - Null Pointer Exception when implementing Notifications with Firebase Messaging 在firebase实时数据库android中使用Uid时出现空指针异常 - null pointer exception while using Uid in firebase realtime database android Firebase google authentication getCurrentUser.getEmail() 返回 null,但它的返回值为 getCurrentUser.getDisplayName() - Firebase google authentication getCurrentUser.getEmail() returns null, but its returning value for getCurrentUser.getDisplayName() 空指针异常与配置 - Null pointer exception with configuration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM