到目前为止,这是我的代码。
public void getimage() {
FirebaseStorage storagi = FirebaseStorage.getInstance();
StorageReference imagerefi = storagi.getReference();
userimage = (ImageView) findViewById(R.id.imageViewuser);
StorageReference pathReference = imagerefi.child("images/"+somename);
imagerefi.child("images/"+somename).getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// Got the download URL for 'users/me/profile.png'
uri2 = uri.toString();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
Glide.with(this).asDrawable().apply(fitCenterTransform()).load(uri2).into(userimage);
}
我尝试过没有成功侦听器和许多其他事情。当我简单地从 firebase 控制台复制粘贴 url 时,我的图像工作正常。但 uri2 不能按预期工作。
我基本上想获取以 firebase 用户 uid 命名的文件,并在 firebase 存储的根目录中名为 images 的文件夹中,并将其显示在 imageview 上。
非常感谢您的帮助!我已经尝试了几个星期来解决这个问题。
//最近从 stactoverflow 帖子中修改了一些代码 //因此在当前配置中没有任何作用,我知道
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句