英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论