简体   繁体   中英

Retrieving and setting an image from firebase storage?

I've been trying to retrieve and set an image from firebase storage for a few hours now and I just can't seem to get it.

I've tried it using the Bitmap and setImageBitmap(), but my app crashes when I load the activity.

I have also tried using Glide. Also crashes my activity. I have tried using different images thinking that may be the cause and still crashes.

My current code is:

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

mStorageReference.getDownloadUrl();

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

using the dependencies:

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'

Since you include FirebaseUI ( firebase-ui-storage ), you don't need to call getDownloadUrl and can pass the StorageReference into Glide directly.

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

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

If this crashes your app, edit your question to include the exact error message and complete stack trace that you get in its logcat output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM