title: ignoring continueWithTask method
body: <p>When you click a button, a photo from the gallery is taken (<code>addPhoto</code> method).</p>
  
  <p>In the onActivityResult method, the photo is uploaded to Firebase Storage with the name of the key (<code>donosId</code> variable) received.</p>
  
  <p>Then, <a href="https://firebase.google.com/docs/storage/android/upload-files?authuser=0#get_a_download_url" rel="nofollow noreferrer">according to the documentation</a>, to obtain the URL of the image, We use the <code>continueWithTask</code> method, inside which the resulting URL is placed in the Firebase Database.</p>
  
  <p>Problem: the <code>continueWithTask</code> method does not start (checked with logs + the URL value remains null). What is the error or how else can you return from the URL method (a variable of type Uri)?</p>
  
  <p>Code:</p>
  
  <pre><code>public void addPhoto(View view) {
          Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
          photoPickerIntent.setType("image/*");
          startActivityForResult(photoPickerIntent, GALLERY_REQUEST);
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          if (requestCode == 1 &amp;&amp; data != null) {
  
              final DatabaseReference newDatabaseReference = FirebaseDatabase.getInstance().getReference("items").push();
  
              donosId = newDatabaseReference.getKey();
  
              final StorageReference imageRef = FirebaseStorage.getInstance().getReference().child("images/" + donosId + ".jpg");
  
              imageRef.putFile(data.getData()).continueWithTask(new Continuation&lt;UploadTask.TaskSnapshot, Task&lt;Uri&gt;&gt;() {
                  @Override
                  public Task&lt;Uri&gt; then(@NonNull Task&lt;UploadTask.TaskSnapshot&gt; task) throws Exception {
                      if (!task.isSuccessful()) {
                          throw task.getException();
                      }
  
                      // Continue with the task to get the download URL
                      return imageRef.getDownloadUrl();
                  }
              }).addOnCompleteListener(new OnCompleteListener&lt;Uri&gt;() {
                  @Override
                  public void onComplete(@NonNull Task&lt;Uri&gt; task) {
                      if (task.isSuccessful()) {
  
                          Uri downloadUri = task.getResult();
  
                          String var = downloadUri.toString();
  
                          Item item = new Item(mNameEditText.getText().toString(),
                                  mSecNameEditText.getText().toString(), var,
                                  (int) System.currentTimeMillis());
                          newDatabaseReference.setValue(item);
  
                      }
                  }
              });
  
          }
      }
  </code></pre>
  
  <p>I don't know why the function isn't running inside and can't access downloadURL, but the image gets uploaded to Firebase Storge.</p>