当前位置: 首页>>代码示例>>Java>>正文


Java UserInfo.getDisplayName方法代码示例

本文整理汇总了Java中com.google.firebase.auth.UserInfo.getDisplayName方法的典型用法代码示例。如果您正苦于以下问题:Java UserInfo.getDisplayName方法的具体用法?Java UserInfo.getDisplayName怎么用?Java UserInfo.getDisplayName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.firebase.auth.UserInfo的用法示例。


在下文中一共展示了UserInfo.getDisplayName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProviderData

import com.google.firebase.auth.UserInfo; //导入方法依赖的package包/类
private void getProviderData() {
    // [START get_provider_data]
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        for (UserInfo profile : user.getProviderData()) {
            // Id of the provider (ex: google.com)
            String providerId = profile.getProviderId();

            // UID specific to the provider
            String uid = profile.getUid();

            // Name, email address, and profile photo Url
            String name = profile.getDisplayName();
            String email = profile.getEmail();
            Uri photoUrl = profile.getPhotoUrl();
        };
    }
    // [END get_provider_data]
}
 
开发者ID:firebase,项目名称:snippets-android,代码行数:20,代码来源:MainActivity.java

示例2: onAuthStateChanged

import com.google.firebase.auth.UserInfo; //导入方法依赖的package包/类
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
    FirebaseUser user = firebaseAuth.getCurrentUser();
    if (user != null && firebaseBugFlag) {
        firebaseBugFlag = false;
        for (UserInfo profile : user.getProviderData()) {
            String providerId = profile.getProviderId();
            if (providerId.equals(FIREBASE_PROVIDER_ID)) {
                if (!user.isAnonymous()) {
                    if (context != null) {
                        String name = profile.getDisplayName();
                        String email = profile.getEmail();
                        Uri photoUrl = profile.getPhotoUrl();
                        String photo = photoUrl != null ? photoUrl.toString() : "";

                        SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
                        SharedPreferences.Editor editor = shared.edit();
                        editor.putString(SSConstants.SS_USER_NAME_INDEX, name);
                        editor.putString(SSConstants.SS_USER_EMAIL_INDEX, email);
                        editor.putString(SSConstants.SS_USER_PHOTO_INDEX, photo);
                        editor.commit();
                    }
                }

                SSEvent.track(SSConstants.SS_EVENT_APP_OPEN);

                openApp();
            }
        }
    }
}
 
开发者ID:Adventech,项目名称:sabbath-school-android,代码行数:32,代码来源:SSLoginViewModel.java

示例3: onCreate

import com.google.firebase.auth.UserInfo; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_userprofile);

    toolbarLayout= findViewById(R.id.tbprofile);
    toolbar= findViewById(R.id.barprofileactivity);
    toolbar.setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp);
    setSupportActionBar(toolbar);
    profileimage= findViewById(R.id.imgprofile);
    mAuth=FirebaseAuth.getInstance();
    user=mAuth.getCurrentUser();
    if (user !=null) {
        for (UserInfo userdata: user.getProviderData()) {

            profileDisplayName=userdata.getDisplayName();
            toolbarLayout.setTitle(profileDisplayName);
            profilePhotoUrl=userdata.getPhotoUrl();
        }
        if (profilePhotoUrl !=null){
            String image=profilePhotoUrl.toString();
            Picasso.with(Userprofile.this)
                    .load(image)
                    .fit()
                    .into(profileimage);
        }else{
            profileimage.setImageDrawable(ContextCompat.getDrawable(Userprofile.this,R.drawable.nouserimage));
        }
    }
    tbs= findViewById(R.id.profiletabs);
    tbs.setSelectedTabIndicatorColor(ContextCompat.getColor(Userprofile.this,R.color.colorAccent));
    vwpgr= findViewById(R.id.profilevpgr);
    adaptadortabs adaptador=new adaptadortabs(getSupportFragmentManager());
    vwpgr.setAdapter(adaptador);
    tbs.setupWithViewPager(vwpgr);

}
 
开发者ID:brunomassa,项目名称:LuxVilla,代码行数:38,代码来源:Userprofile.java

示例4: getUserDetails

import com.google.firebase.auth.UserInfo; //导入方法依赖的package包/类
/**
 * get user details
 *
 * @return UserModel
 */
public static UserModel getUserDetails() {
    final FirebaseUser user = getFirebaseNewInstance().getCurrentUser();
    if (user == null)
        return null;

    String name = user.getDisplayName();
    String email = user.getEmail();
    String picture = user.getPhotoUrl() != null ? user.getPhotoUrl().toString() : null;
    for (UserInfo userInfo : user.getProviderData()) {
        if (name == null && userInfo.getDisplayName() != null) {
            name = userInfo.getDisplayName();
        }

        if (email == null && userInfo.getEmail() != null) {
            email = userInfo.getEmail();
        }
    }

    // Tag
    Map<String, Boolean> tags = new HashMap<>();
    tags.put(DatabaseConstants.TAG_OTHERS, true);
    tags.put(DatabaseConstants.TAG_ANDROID, false);
    tags.put(DatabaseConstants.TAG_IOS, false);
    tags.put(DatabaseConstants.TAG_RUBY, false);
    tags.put(DatabaseConstants.TAG_PYTHON, false);
    tags.put(DatabaseConstants.TAG_NODEJS, false);

    return new UserModel(
            getCurrentUserId(),
            null,
            null,
            null,
            email,
            name,
            picture,
            0,
            false,
            tags,
            null);
}
 
开发者ID:RubitOrganization,项目名称:Rubit,代码行数:46,代码来源:FirebaseUtils.java


注:本文中的com.google.firebase.auth.UserInfo.getDisplayName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。