Try to get URL of image uploaded in Firebase Storage, using this docs, but there's no info about how to return downloadUri
value from Task.continueWithTask
method.
Even method documentation doesn't helped to understand.
Quote from docs, there's no explanation how to get this URL:
After uploading a file, you can get a URL to download the file by calling the getDownloadUrl() method on the StorageReference:
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
// ...
}
}
});