I want to update dialog\'s download progress from doInBackground.
I am printing log as well as publishing progress.
Neither of them are working.
It up
One possible explanation for the behaviour is that reading from remote input stream and writing it into output buffer is extremely fast. I tried the same code but with just a loop running for 10 times.
int total = 0;
while(total <= 100){
progress = total;
total += 10;
publishProgress();
}
Even I could not see the progress dialog at first, so put a Thread.sleep() in the loop and the progress dialog works just fine.
int total = 0;
while(total <= 100){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
progress = total;
total += 10;
publishProgress();
}
Try to log the time (System.currentTimeMillis()
) at which you are writing into the output buffer.
Hope it helps.
remove super from onProgressUpdate and then try
@Override
protected void onProgressUpdate(Void... values) {
//super.onProgressUpdate(values);
mProgressDialog.setProgress(progress);
}
if it doesn't work than add a sleep statement in your loop so that this loop will free the processor and give time to publish the progress
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}