Q:

data not passing when running doInBackground method within for loop

I have some pics to upload to the ftp server and I am using Asynctask for it. The images need to be sent to multiple host so I am using a for loop. The data to be passed is very well being fetched by the constructor but the doInBackground method is not running which was earlier running very well without the for loop and the additional data apart from the String filePathName that I am trying to pass in now in doInBackground.please help me
class uploadTask extends AsyncTask<String, Void, String> {
    public uploadTask(String filePathName,String host_2,String user_2,String pass_2)
    {
        filePath=filePathName;
        host_1=host_2;
        user_1=user_2;
        pass_1=pass_2;
        Toast.makeText(getBaseContext(),"FTP DATA RECEIVING:"+"HOST:"+host_2+" USERNAME:"+user_2+" PASS:"+pass_2,Toast. LENGTH_LONG).show();
        //hostName=host;
    }
    @Override
    protected String doInBackground(String... params) {
        try {

            Toast.makeText(getBaseContext(),"Entered Do in Background Method to upload",Toast. LENGTH_SHORT).show();
            ftp_host = "ftp.photoshelter.com";//This is not the correct way.  Supposed to get from Backendless table
            ftp_username = "brytest";//This is not the correct way.  Supposed to get from Backendless table
            ftp_password = "passtest";//This is not the correct way.  Supposed to get from Backendless table
            Toast.makeText(getBaseContext(),"HOST:"+ftp_host+" USERNAME:"+ftp_username+" PASS:"+ftp_password,Toast. LENGTH_LONG).show();
            news_agency = "news agency";
            easyFTP ftp = new easyFTP();
            ftp.connect(ftp_host, ftp_username, ftp_password);
            status = ftp.setWorkingDirectory("mem/images"); // if User say provided any Destination then Set it , otherwise
            // Upload will be stored on Default /root level on server
            String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
            String imageTimeStamped = ftp_username + "_" + timeStamp + ".png";
            FileInputStream is = new FileInputStream(imageFileLocation);
            //addPhotoGrapherInfo();

            ftp.uploadFile(is, imageTimeStamped);
            System.out.println("Successfull ftp upload to " + ftp_host);
            Toast.makeText(getBaseContext(), "Photo uploading by ftp to " + ftp_host, Toast. LENGTH_LONG).show();
        //}
                //reset booleans
                //cameraPicTaken = false;
                //galleryImageSelected = false;
                //System.out.println("reset cameraPicTaken and galleryImageSelected");
           // }
                return new String("Upload Successful");
        }catch (Exception e){
            String t="Failure : " + e.getLocalizedMessage();
            return t;
        }
    }
}

my onClickListener with for loop
 if(cameraPicTaken || galleryImageSelected) {
                Toast.makeText(SubmitActivity.this,"Image Location is:"+ imageFileLocation,Toast. LENGTH_LONG).show();
                //addPhotoGrapherInfo();
                for(int i=0;i<Common.selectedHostArray.size();i++) {
                    uploadFile(imageFileLocation,Common.selectedHostArray.get(i),Common.selectedUsernameArray.get(i),Common.selectedPasswordArray.get(i));
                }
                cameraPicTaken = false;
                galleryImageSelected = false;
            }

funnction called in onClick
public void uploadFile(String filePath,String host_1,String user_1,String pass_1)
{
    if(cameraPicTaken == true) {
        System.out.println("camera photo start upload");
        //for(int i=0;i<Common.selectedHostArray.size();i++) {
            //host_1=Common.selectedHostArray.get(i);
            //user_1=Common.selectedUsernameArray.get(i);
            //pass_1=Common.selectedPasswordArray.get(i);
            //host_1="ftp.photoshelter.com";
            //user_1="brytest";
            //pass_1="passtest";
        Toast.makeText(getBaseContext(),"FTP DATA PASSING:"+"HOST:"+host_1+" USERNAME:"+user_1+" PASS:"+pass_1,Toast. LENGTH_LONG).show();
            new uploadTask(filePath,host_1,user_1,pass_1).execute();
       // }
        //cameraPicTaken = false;
        //galleryImageSelected = false;
        System.out.println("reset cameraPicTaken and galleryImageSelected");
      //cameraPicTaken = false;

    }
    if(galleryImageSelected == true){
        System.out.println("gallery image start upload");
        Toast.makeText(getBaseContext(),"FTP DATA PASSING:"+"HOST:"+host_1+" USERNAME:"+user_1+" PASS:"+pass_1,Toast. LENGTH_LONG).show();
        new uploadTask(filePath,host_1,user_1,pass_1).execute();
        //new uploadTask(filePat)h.execute();
        //galleryImageSelected = false;
    }

    Toast.makeText(getBaseContext(), "Photo uploading by ftp to photoshelter.com" /*+ news_agency*/, Toast. LENGTH_LONG).show();
}

A:

You're trying to perform a UI command on a background thread (Toast).  This is causing your background tasks to fail early.  Since your background tasks catch their own errors, they fail silently. 
@Override
protected String doInBackground(String... params) {
    try {
        // you can't Toast on a background thread, this should throw an exception
        Toast.makeText(getBaseContext(),"Entered Do in Background Method to upload",Toast. LENGTH_SHORT).show();
        ...
    }catch (Exception e){
        // your Toast exception is getting caught silently here
        String t="Failure : " + e.getLocalizedMessage();
        return t;
    }
}

By the way, the try/catch on everything is not a good practice.  You end up with a ton of silent failures leaving you scratching your head and asking why things aren't working.