Problems with getDownloadUrl firebase

Asked

Viewed 803 times

0

Hi, I’m having a hard time getDownloadUrl firebase.

After the last firebase update my app stopped working.

Is showing error in Uri downloadUrl = taskSnapshot.getDownloadUrl();

        uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Uri downloadUrl = taskSnapshot.getDownloadUrl();

                Map newImage = new HashMap();
                newImage.put("profileImageUrl", downloadUrl.toString());
                mCustomerDatabase.updateChildren(newImage);

                finish();
                return;
            }
        });

Displays the error

inserir a descrição da imagem aqui

  • Which error is being presented?

  • I just added a photo with the error I’m going through

  • Can with taskSnapshot.getDownloadUrlAsync()?

1 answer

0


This method was removed in favor of StorageReference.getDownloadUrl(). This method returns a Task<Uri>. Then you have to add a Istener to the Task to get the downloadUrl:

uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                    @Override
                    public void onSuccess(Uri downloadUrl) {

                        Map newImage = new HashMap();
                        newImage.put("profileImageUrl", downloadUrl.toString());
                        mCustomerDatabase.updateChildren(newImage);

                        finish();
                    }
                });

            }
        });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.