Android 安卓Firebase“;UserProfileChangeRequest“;正在运行,但在用户注销并再次登录后无法运行

Android 安卓Firebase“;UserProfileChangeRequest“;正在运行,但在用户注销并再次登录后无法运行,android,authentication,firebase,Android,Authentication,Firebase,我正在学习安卓Firebase。当我编写一个注册用户代码时,它成功地工作了。但是当我调用“userProfileChangeRequest”方法时 若要更改用户名或配置文件图片uri,必须成功完成,但在用户注销并再次登录之前,无法查看新数据 为什么??有什么问题 这是我的密码: private void getUriPicture() { if(uriImage == null){ //user didn't select profile picture

我正在学习安卓Firebase。当我编写一个注册用户代码时,它成功地工作了。但是当我调用“userProfileChangeRequest”方法时 若要更改用户名或配置文件图片uri,必须成功完成,但在用户注销并再次登录之前,无法查看新数据

为什么??有什么问题

这是我的密码:

private void getUriPicture() {

     if(uriImage == null){
            //user didn't select profile picture
          return;
        }
        else if(!App.isOnline(this)) {
             Toast.makeText(this, getResources().getString(R.string.checkInternetConnection), Toast.LENGTH_SHORT).show();
             return;
         }else{
         mStorage = FirebaseStorage.getInstance().getReference();

         //upload picture to get Path
         Log.e(TAG,"test3");
            StorageReference path = mStorage.child("ProfilePicture").child(uriImage.getLastPathSegment()
                    + "_"
                    + App.randomNumber()
                    + "_"
                    + App.randomNumber());

         Log.e(TAG,"test4"+path);
            path.putFile(uriImage).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    Log.e(TAG,"Upload success");
                    @SuppressWarnings("VisibleForTests") Uri downloadUrl= taskSnapshot.getDownloadUrl();

                    //Preview profile picture before set it to user
                    Picasso.with(Setting.this).load(downloadUrl).into(profilePicture);
                    setUserProfilePicture(downloadUrl);

                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    TF=false;
                    Toast.makeText(Setting.this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();

                }
            });
        }



    }


private void setUserProfilePicture(Uri downloadUrl) {

        //mProgress.setMessage(getResources().getString(R.string.updateProfile));

        FirebaseUser user = mAuth.getCurrentUser();

        if(user != null) {
            Log.e(TAG,"test6");
            UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
                    .setPhotoUri(downloadUrl)
                    .build();
            user.updateProfile(profileUpdates)
                    .addOnCompleteListener(new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {
                            if (task.isSuccessful()) {
                                Log.e(TAG, "Update Profile Successful");
                                Toast.makeText(Setting.this, getResources().getString(R.string.updateSuccessful), Toast.LENGTH_SHORT).show();
                            }
                        }
                    }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.e(TAG, "Update Failure");
                    Toast.makeText(Setting.this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
                }
            });
        }
    }
private void getUriPicture(){
如果(uriImage==null){
//用户未选择个人资料图片
返回;
}
如果(!App.isOnline(此)){
Toast.makeText(this,getResources().getString(R.string.checkInternetConnection),Toast.LENGTH_SHORT.show();
返回;
}否则{
mStorage=FirebaseStorage.getInstance().getReference();
//上传图片以获取路径
Log.e(标签“test3”);
StorageReference path=mStorage.child(“ProfilePicture”).child(uriImage.getLastPathSegment()
+ "_"
+App.randomNumber()
+ "_"
+App.randomNumber());
Log.e(标签,“test4”+路径);
path.putFile(uriImage.addOnSuccessListener(新的OnSuccessListener()){
@凌驾
成功时公共无效(UploadTask.TaskSnapshot TaskSnapshot){
Log.e(标记“上传成功”);
@SuppressWarnings(“VisibleForTests”)Uri downloadUrl=taskSnapshot.getDownloadUrl();
//预览配置文件图片,然后将其设置为用户
毕加索.with(Setting.this).load(downloadUrl).into(profilePicture);
setUserProfilePicture(下载URL);
}
}).addOnFailureListener(新的OnFailureListener(){
@凌驾
public void onFailure(@NonNull异常e){
TF=假;
Toast.makeText(Setting.this,e.getLocalizedMessage(),Toast.LENGTH_SHORT).show();
}
});
}
}
私有void setUserProfilePicture(Uri下载URL){
//setMessage(getResources().getString(R.string.updateProfile));
FirebaseUser=mAuth.getCurrentUser();
如果(用户!=null){
Log.e(标签“test6”);
UserProfileChangeRequest profileUpdates=新建UserProfileChangeRequest.Builder()
.setPhotoUri(下载URL)
.build();
user.updateProfile(profileUpdates)
.addOnCompleteListener(新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
if(task.issusccessful()){
Log.e(标记“更新配置文件成功”);
Toast.makeText(Setting.this,getResources().getString(R.string.updateSuccessful),Toast.LENGTH_SHORT.show();
}
}
}).addOnFailureListener(新的OnFailureListener(){
@凌驾
public void onFailure(@NonNull异常e){
Log.e(标签“更新失败”);
Toast.makeText(Setting.this,e.getLocalizedMessage(),Toast.LENGTH_LONG.show();
}
});
}
}

也许您可以尝试更新onCompleteListener内UI中的用户映像?因为在UserProfileChangeRequest之后没有执行视图更新操作

谢谢你的回答。。。但是,当我调用“user.getPhotoUrl”或“user.getDisplayName”时,在我重新登录时检索到一个旧数据,该数据被刷新