Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从firebase存储中检索和设置图像?_Java_Android_Firebase_Firebase Storage - Fatal编程技术网

Java 从firebase存储中检索和设置图像?

Java 从firebase存储中检索和设置图像?,java,android,firebase,firebase-storage,Java,Android,Firebase,Firebase Storage,几个小时以来,我一直在尝试从firebase存储中检索和设置图像,但似乎无法获取它 我尝试过使用位图和setImageBitmap(),但当我加载活动时,我的应用程序崩溃 我也尝试过使用Glide。也会破坏我的活动。我尝试过使用不同的图像,认为这可能是原因,但仍然崩溃 我目前的代码是: mStorageReference = FirebaseStorage.getInstance().getReference().child(photoUrl); mStorageReference.getDo

几个小时以来,我一直在尝试从firebase存储中检索和设置图像,但似乎无法获取它

我尝试过使用位图和setImageBitmap(),但当我加载活动时,我的应用程序崩溃

我也尝试过使用Glide。也会破坏我的活动。我尝试过使用不同的图像,认为这可能是原因,但仍然崩溃

我目前的代码是:

mStorageReference = FirebaseStorage.getInstance().getReference().child(photoUrl);

mStorageReference.getDownloadUrl();

Glide.with(this).load(mStorageReference).into(phProfilePhoto);
使用依赖项:

implementation 'com.github.bumptech.glide:glide:4.11.0'

annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

implementation 'com.firebaseui:firebase-ui-storage:6.3.0'

由于您包括FirebaseUI(
firebase ui存储
),因此不需要调用
getDownloadUrl
,并且可以将
StorageReference
直接传递到Glide中

mStorageReference = FirebaseStorage.getInstance().getReference().child(photoUrl);

Glide.with(this).load(mStorageReference).into(phProfilePhoto);

如果这使你的应用程序崩溃,请编辑你的问题,使其包含在logcat输出中得到的确切错误消息和完整堆栈跟踪。

我添加了侦听器,但它仍在使我的应用程序崩溃。它成功了,但在滑翔线上崩溃了。使用(this).load(mStorageReference).into(imageView);使用logcat帮助您,谢谢!以前从未真正使用过,直到现在。phProfilePhoto指向不同活动smh中的图像视图。