0

I am sending data to web server using asynctask task class. So I am taking all value from SQLite in one array list and in for loop I'm calling asynctask class to send data but the problem is loop finishes its execution and send only last value from array list to the web service. But the web service is calling according to for loop.

Any suggestion would be helpful.

Following is my code:

for (int i = 0; i < outletMasterList.size(); i++) {
    outletMaster = outletMasterList.get(i);
    outlet_Code = outletMaster.getOutletCode();
    outlet_UID = outletMaster.getOutletUID();
    finalValue = AppConstant.IMEI_NUMBER;
    System.out.println("Sync i  : : : : " + i + " " + respose_count);
    new CommonAsyncTaskWithoutProgressBar(Sync.this, callbackInterface)
    .execute("0",
    AppConstant.NAMESPACE,
    AppConstant.METHOD_NAME,
    AppConstant.ACCESS_KEY,
    AppConstant.Set_OutletFromHH,
    AppConstant.OutletSyncParameters, finalValue);
}
  • You should show code for your async task. Also it's not how are passing paramtres to the CommonAsyncTaskWithoutProgressBar. Variables outletMaster, outlet_Code etc are not used whent executing async task. But there are some static variables, what is in them and how are they setup? Where does inputParam come from? – Josef Adamcik Jul 21 '17 at 12:36
  • My guess is you are sharing object with data for async task with all instances and becasue they are run asychronously they work with the same value. – Josef Adamcik Jul 21 '17 at 12:38
  • you should check this link https://stackoverflow.com/questions/11389903/asynctask-inside-a-loop and https://stackoverflow.com/questions/26067970/execution-order-in-asynctask-inside-loop – Mohit Suthar Jul 21 '17 at 13:24
  • i am writing this code on button click – developer android Jul 22 '17 at 06:16

0 Answers0