如何使用来自 firebase 存储的图片设置 imageview

How to set an imageview with a picture from firebase storage

我正在尝试检索从 firebase 存储中手动上传的图像,并在应用程序的图像视图中显示它们。我在下面尝试了这种方法。我使用下面代码的原因是因为将来我想通过简单地删除数据库中的图像并将其替换为与之前同名的新图像来更改图像。例如,我的 firebase 中名为 'A' 的树的图像被删除并替换为名为 'A'

的狗的图像
private FirebaseStorage storage=FirebaseStorage.getInstance();
private ImageView mIm;
private StorageReference 

.....

mIm=(ImageView)findViewById(R.id.imageViewtiko);
    final long ONE_MEGABYTE=1024*1024;
    storageRef.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
        @Override
        public void onSuccess(byte[] bytes) {
            Bitmap bitmap=BitmapFactory.decodeByteArray(bytes,0,bytes.length);
            mIm.setImageBitmap(bitmap);
        }
    });

应用程序在 运行 时不会崩溃,也不会出现错误消息,但它只是不显示图像。请帮助

我只是添加了一个 onFailureListener,它工作正常