and-nd-firebase
and-nd-firebase copied to clipboard
taskSnapshot.getDownloadUrl() doesn't exist.
https://github.com/udacity/and-nd-firebase/blob/a8b875ac763f0b2d845154b5faace9e685d2326f/app/src/main/java/com/google/firebase/udacity/friendlychat/MainActivity.java#L202
I believe solution is @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { Task<Uri> urlTask = taskSnapshot.getStorage().getDownloadUrl(); while (!urlTask.isSuccessful()); Uri downloadUrl = urlTask.getResult(); //rest }
try this bro
photoRef.putFile(selectedImageUri).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(); } return photoRef.getDownloadUrl(); } }).addOnCompleteListener(new OnCompleteListener<Uri>() { @Override public void onComplete(@NonNull Task<Uri> task) { if (task.isSuccessful()) { Uri downloadUri = task.getResult(); FriendlyMessage friendlyMessage = new FriendlyMessage(null, mUsername, downloadUri.toString()); mMessageDatabaseReference.push().setValue(friendlyMessage); } else { Toast.makeText(MainActivity.this, "upload failed: " + task.getException().getMessage(), Toast.LENGTH_SHORT).show(); } } });