title: How to return a value after onSuccess is finished?
body: <p>I'm having a little trouble, im executing a method in my doinBackground task, so I'm getting a crash because im accesing to another class without finishing this method first, so i want to add a return or something to let the method know when it needs to launch the other activity. I have searched and I can't return a boolean, true or false into Firebase asynctask method. This is the method I use to download a file and replace it into internal memory, but when im doing this , the other activity I need to launch after this launches and i get a crash, so i need to first execute this download task and then if something is true launch my other activity</p>
  
  <p>This is where I want to put a boolean or something that tells me that the download finished.</p>
  
  <pre><code>public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
                  Log.e("TamañoArchivo",""+taskSnapshot.getTotalByteCount());
                  Log.e("NombreArchivo",""+xFile);
  
                  try {
                      FileOutputStream fos = context.openFileOutput("pictos.txt", Context.MODE_PRIVATE);
                      fos.write(getStringFromFile(xFile.getAbsolutePath()).getBytes());
                      Log.e("xFILEDESCARGARPAIS",""+getStringFromFile(xFile.getAbsolutePath()));
                      fos.close();
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
  </code></pre>
  
  <p>The method is not an asyncTask, is an async but from Firebase, this is the method:</p>
  
  <pre><code>public boolean DescargarArchivosPais(String locale){
  
          File rootPath = new File(context.getCacheDir(),"MY_FILES");
          if(!rootPath.exists()) {
              rootPath.mkdirs();//si no existe el directorio lo creamos
          }
  
          StorageReference mStorageRef2 = FirebaseStorage.getInstance().getReference().child("Files/y/" + "y_" + locale + "." + "txt");
          StorageReference mStorageRef1 = FirebaseStorage.getInstance().getReference().child("Files/x/" + "x_" + locale + "." + "txt");
          Log.e("REFERENCIAx",""+ mStorageRef1);
          Log.e("REFERENCIAy",""+ mStorageRef2);
  
          final File xFile = new File(rootPath, "x.txt");
          final File yFile = new File(rootPath, "y.txt");
  
          mStorageRef1.getFile(xFile).addOnSuccessListener(new OnSuccessListener&lt;FileDownloadTask.TaskSnapshot&gt;() {
              @Override
              public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
  
                  Log.e("TamañoArchivo",""+taskSnapshot.getTotalByteCount());
                  Log.e("NombreArchivo",""+xFile);
  
                  try {
  
                      FileOutputStream fos = context.openFileOutput("x.txt", Context.MODE_PRIVATE);
                      fos.write(getStringFromFile(xFile.getAbsolutePath()).getBytes());
                      Log.e("LOG",""+getStringFromFile(xFile.getAbsolutePath()));
                      fos.close();
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
  
  
              }
          }).addOnFailureListener(new OnFailureListener() {
              @Override
              public void onFailure(@NonNull Exception e) {
  
              }
          });
  
          mStorageRef2.getFile(yFile).addOnSuccessListener(new OnSuccessListener&lt;FileDownloadTask.TaskSnapshot&gt;() {
              @Override
              public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
  
                  Log.e("TamañoArchivo",""+taskSnapshot.getTotalByteCount());
                  Log.e("NombreArchivo",""+yFile);
  
                  try {
                      FileOutputStream fos = context.openFileOutput("y.txt", Context.MODE_PRIVATE);
                      fos.write(getStringFromFile(gruposFile.getAbsolutePath()).getBytes());
                      Log.e("LOG2",""+getStringFromFile(gruposFile.getAbsolutePath()));
                      fos.close();
                      fSuccess = true;
                  } catch (Exception e) {
                      e.printStackTrace();
                      Log.e("printStackTrace",""+e.toString());
                      fSuccess = false;
                  }
                  fSuccess = true;
              }
          }).addOnFailureListener(new OnFailureListener() {
              @Override
              public void onFailure(@NonNull Exception e) {
                  fSuccess=false;
                  Log.e("printStackTrace",""+e.toString());
              }
  
          });
          return fSuccess;
      }
  </code></pre>