0

As taskSnapshot.getDownloadUrl() is depperacted so I followed the firebase post as to get the URL

final StorageReference ref = storageRef.child("images/mountains.jpg");
uploadTask = ref.putFile(file);

 Task<Uri> urlTask = uploadTask.continueWithTask(new        Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
    if (!task.isSuccessful()) {
        throw task.getException();
    }

    // Continue with the task to get the download URL
    return ref.getDownloadUrl();
}
   }).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
    if (task.isSuccessful()) {
        Uri downloadUri = task.getResult();
    } else {
        // Handle failures
        // ...
    }
}
});

but I want

 String downloadUri = taskSnapshot.getDownloadUrl().toString();

instead of

 Uri downloadUri = task.getResult();

How I can do this???

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Manik
  • 153
  • 4
  • 15

1 Answers1

0

After some researches I came to know the answer by changing:

String downloadUrii = downloadUri.toString();

will be the solution

Leon
  • 2,926
  • 1
  • 25
  • 34
Manik
  • 153
  • 4
  • 15