Came across this solution during development of messaging app. My problem was that the download URL of the profile image was not saving as an actual URL in my firebase database, but this solution worked. My problem is that I can not understand the use of the while loop. I understand how the loop works, keeps repeating until task.isSuccessful() returns true, but I do not understand why it was used as such.

filepath.putFile(resultUri).addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

       Task<Uri> urlTask = taskSnapshot.getStorage().getDownloadUrl();
       while (!urlTask.isSuccessful());
       Uri downloadUrl = urlTask.getResult();

       final String sdownload_url = String.valueOf(downloadUrl);

Related posts

Recent Viewed