I have this code in doInBackground method of an AsyncTask:
for (int i = 0; i < lenght; i++) {
// Do something
count++;
publishProgress(count * 100 / lenght);
}
and all works fine. If i add another operation, how to reflect this with the progress bar?
Now i have this code:
for (int i = 0; i < lenght1; i++) {
// Do something
count++;
publishProgress(count * 100 / lenght1);
}
for (int i = 0; i < lenght2; i++) {
// Do something
count++;
publishProgress(count * 100 / lenght2);
}
How to make the bar start from 0 when operation 1 starts and finish at 100 when operation 2 ends? I tried to change count*100 to count*50 but it seems not to be the right way...