0

I´m trying to make an app to upload images and then fetch them to another screen following a tutorial. However, I haven´t been able to complete a line because it won´t find getDownloadUrl.

I investigated, and I know it is deprecated, but I can´t find a way to put it to complete the line.

private void uploadFiles(){
        if (mImageUri != null){
            StorageReference fileReference =  mStorageRef.child(System.currentTimeMillis() + "." + getFileExtension(mImageUri));

           mUploadTask = fileReference.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    Handler handler  = new Handler();
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            pBar.setProgress(0);
                        }
                    }, 5000);
                    Toast.makeText(enviarEvidencias.this, "Subida Exitosa", Toast.LENGTH_LONG).show();
                    **upload upload = new upload(text.getText().toString().trim(),
                            taskSnapshot.getDownloadUrl.toString());**

                    String uploadId = mDatabaseRef.push().getKey();
                    mDatabaseRef.child(uploadId).setValue(upload);
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Toast.makeText(enviarEvidencias.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onProgress(@NonNull UploadTask.TaskSnapshot snapshot) {
                    double progress = (100.0 * snapshot.getBytesTransferred() / snapshot.getTotalByteCount());
                    pBar.setProgress((int) progress);
                }
            });
        }else{
            Toast.makeText(this, "No file selected", Toast.LENGTH_SHORT).show();
        }
    }
gru
  • 1,305
  • 4
  • 12
  • 24
Diego Alv.
  • 11
  • 1
  • Check this https://stackoverflow.com/questions/50554548/error-cannot-find-symbol-method-getdownloadurl-of-type-com-google-firebase-st – Zain Jan 24 '22 at 19:02

0 Answers0