Image not loading with picasso or glide..keeps displaying black background

前端 未结 1 2005
后悔当初
后悔当初 2021-01-29 04:29

I\'m trying to load an image from firebase database using picasso, but no matter what I try it keeps doing the same thing ... I even tried using glide

Here\'s what\'s h

相关标签:
1条回答
  • 2021-01-29 04:47

    When you use the following line

    final String downloadUrl = filePath.getDownloadUrl().toString();
    

    filePath.getDownloadUrl() returns the task ID (com.google.android.gms.tasks.zzu@f30b587) which you then save to the database instead of the actual url , so when you use the following line to get the url (to load the image in via picasso) you are just getting the upload id! No a usable url.

    String image = dataSnapshot.child("profileimage").getValue(String.class);
    

    To fix this you need to get the download url in an async task after firebase storage upload. As per https://firebase.google.com/docs/storage/android/upload-files#get_a_download_url

    Then add the actual url to the firebase database which links the database to the stored image :) I'm sure there a more elegant method but this works.

    0 讨论(0)
提交回复
热议问题