Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – task.getResult().getDownloadUrl().toString() is not working/accepted

Posted on November 14, 2022

Solution 1 :

I guess you need to get it directly from storageReference , so do as following :

Uri downloadUrl = filePath.getDownloadUrl();

Problem :

This question already has answers here:

How to get URL from Firebase Storage getDownloadURL

(13 answers)
Closed 2 years ago.

Please check the code i am getting an error at getDownloadUrl() method. As it is not being accepted by the firebase. I am a beginner at this, so can anyone please suggest the changes i have to make in this code.

This snippet is basically focused on getting the image url from the storage and add it in the database section in firebase. But the getDownloadUrl is not working, please suggest the changes in the snippet to make it happen.

            StorageReference filePath = userProfileImagesReference.child(currentUserID + ".jpg");

            filePath.putFile(resultUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
                    if(task.isSuccessful())
                    {
                        Toast.makeText(SettingsActivity.this, "Profile Image Uploaded", Toast.LENGTH_SHORT).show();

                        //error here
                        final String downloadURL = task.getResult().getDownloadUrl().toString();

                        rootRef.child("Users").child(currentUserID).child("image")
                                .setValue(downloadURL)
                                .addOnCompleteListener(new OnCompleteListener<Void>() {
                                    @Override
                                    public void onComplete(@NonNull Task<Void> task) {
                                        if(task.isSuccessful())
                                        {
                                            Toast.makeText(SettingsActivity.this, "Image Saved", Toast.LENGTH_SHORT).show();
                                            loadingBar.dismiss();
                                        }
                                        else
                                        {
                                            String errorMSG = task.getException().toString();
                                            Toast.makeText(SettingsActivity.this, "Error: "+errorMSG, Toast.LENGTH_SHORT).show();
                                        loadingBar.dismiss();
                                        }
                                    }
                                });


                    }
                    else
                    {
                        String error = task.getException().toString();
                        Toast.makeText(SettingsActivity.this, "Error: "+error, Toast.LENGTH_SHORT).show();
                        loadingBar.dismiss();
                    }
                }
            });

Comments

Comment posted by firebase.google.com/docs/storage/android/…

You’re not using the API correctly. getDownloadUrl returns a Task that gives you the URL asynchronously. I suggest reviewing the documentation.

Comment posted by Ekta Dushanj

Could you please add the exception you are getting.

Comment posted by Doug Stevenson

That won’t work either.

Comment posted by Taki

did you log the downloadUrl , are you getting null value ?

Comment posted by Taki

it worked for me because i m working on a project with firebase and its components too

READ  [ANSWERED] android - WorkManager + Hilt FAILED
Powered by Inline Related Posts

Comment posted by Doug Stevenson

Trust me, it won’t work. You will get a string, but it won’t be a download URL string.

Comment posted by pastebin.com/dpYaFwcp

Trust me it does work and here is my code for you

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress