如何检查我的 firebaseUser 是否包含任何 displayName?

huangapple go评论75阅读模式
英文:

How to check my firebaseUser contains any displayName or not?

问题

以下是翻译好的内容:

无论是这个(如果 firebaseUser.getDisplayName()!=null)还是下面的一个都对我不起作用:

@Override
protected void onStart() {
    super.onStart();
    FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
    if (firebaseUser.getDisplayName() == null || firebaseUser.getDisplayName().trim().length() == 0){
        startActivity(new Intent(SecondActivity.this, MainActivity.class));
        finish();
    }
}
英文:

Neither (if firebaseUser.getDisplayName()!=null) this nor the below one is working for me:

@Override
protected void onStart() {
    super.onStart();
    FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
    if (firebaseUser.getDisplayName() == null || firebaseUser.getDisplayName().trim().length() == 0){
        startActivity(new Intent(SecondActivity.this, MainActivity.class));
        finish();
    }
}

答案1

得分: 1

根据你的评论:

> 不,FirebaseUser 包含UID,但 UID 是否包含 DisplayName 是我关心的问题。

是的,FirebaseUser 对象包含 UID 以及名称。getDisplayName() 方法将始终返回名称,就像 getUid() 返回 UID 一样。getDisplayName() 不可能返回 UID,因为 getUid() 方法不可能返回名称。

英文:

According to your comment:

> No, FirebaseUser contains the UID but do the UID contains the DisplayName is my concern

Yes, FirebaseUser object contains the UID, as well as the name. The getDisplayName() will always return the name, as well as the getUid() returns the UID. There is no way in which getDisplayName() can return the UID as it is not possible that the getUid() method to return the name.

huangapple
  • 本文由 发表于 2020年5月29日 20:50:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/62086452.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定