App Crashes While Retrieve Downloadurl.result
As soon as I try to retrieve the downloadUrl of my upload (upload works fine) with downloadUrl.result the app crashes. The app does not crash when using downloadUrl.toString() inst
Solution 1:
I solved it now. The task was not finished yet. That is why i could not retrieve the downloadUrl. Added an OnCompleteListener...
taskSnapshot.storage.downloadUrl.addOnCompleteListener{
task ->if(task.isSuccessful){
profileImageUrl = task.result
}else{
Log.d("Crash", "Crash starts here")
}
Solution 2:
try this:
storageReference.putFile(postImageUri).addOnCompleteListener(newOnCompleteListener<UploadTask.TaskSnapshot>() {
@OverridepublicvoidonComplete(@NonNull final Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful())
{
String downloadUri = task.getResult().getDownloadUrl().toString();
Map<String, Object> postMap = newHashMap<>();
postMap.put("image_download_uri",downloadUri);
postMap.put("post_title",title);
postMap.put("current_user_id",current_user_id);
postMap.put("current_time",currentTime.toString());
postMap.put("timestamp", FieldValue.serverTimestamp());
Post a Comment for "App Crashes While Retrieve Downloadurl.result"