Open hamidsn opened 6 years ago
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 urlTask = taskSnapshot.getStorage().getDownloadUrl(); while (!urlTask.isSuccessful()); Uri downloadUrl = urlTask.getResult(); //rest }
try this bro
photoRef.putFile(selectedImageUri).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task>() { @Override public Task then(@NonNull Task task) throws Exception { if (!task.isSuccessful()) { throw task.getException(); } return photoRef.getDownloadUrl(); } }).addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task 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(); } } });
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 urlTask = taskSnapshot.getStorage().getDownloadUrl();
while (!urlTask.isSuccessful());
Uri downloadUrl = urlTask.getResult();
//rest
}