当我从FirebaseUser用户名和UserPhotoURI获取时 username = null UsePhotoUri = null
这是我的注册代码
rAuth.createUserWithEmailAndPassword(username,password_user).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()){
rAuth.signInWithEmailAndPassword(username,password_user).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful())
{
FirebaseUser userFire = FirebaseAuth.getInstance().getCurrentUser();
UserProfileChangeRequest updateprofile = new UserProfileChangeRequest.Builder()
.setDisplayName(userName.getText().toString().trim())
.setPhotoUri(userphotourl).build();
userFire.updateProfile(updateprofile);
}
}
});
SingIn(view);
}
else{Toast.makeText(getApplicationContext(),"Не удалось зарегистрироваться пжалуйта проверьте подключение к интернету",Toast.LENGTH_SHORT).show();}
}
});
为什么我的displayname = null
在此代码中,我阅读了用户帐户
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile_actv);
mAuth = FirebaseAuth.getInstance();
USER = mAuth.getInstance().getCurrentUser();
Toast.makeText(this,mAuth.getCurrentUser().getDisplayName() + " " + mAuth.getCurrentUser().getEmail(),Toast.LENGTH_SHORT).show();
ProfileName = (EditText) findViewById(R.id.PName);
ProfileEmail = (EditText) findViewById(R.id.PEmail);
ProfileImage = (ImageView) findViewById(R.id.imageView3);
UpdateProfile = (Button) findViewById(R.id.UProfile);
if(USER != null)
{
ProfileName.setText(USER.getDisplayName());
ProfileEmail.setText(USER.getEmail());
ProfileImage.setImageURI(USER.getPhotoUrl());
}
}