Progressbar for two or more operations <p>I have this code in doInBackground method of an AsyncTask:</p> <pre><code> for (int i = 0; i &lt; lenght; i++) { // Do something count++; publishProgress(count * 100 / lenght); } </code></pre> <p>and all works fine. If i add another operation, how to reflect this with the progress bar?</p> <p>Now i have this code:</p> <pre><code> for (int i = 0; i &lt; lenght1; i++) { // Do something count++; publishProgress(count * 100 / lenght1); } for (int i = 0; i &lt; lenght2; i++) { // Do something count++; publishProgress(count * 100 / lenght2); } </code></pre> <p>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...</p>