Will this make the current UI thread to sleep?
try
{
Thread.sleep(20);
onProgressUpdate(i);
} catch (InterruptedException e) {
e.printStackTrace
If you are calling sleep on the ui thread it blocks the ui thread. Do not call sleep on the ui thread. You should not block the ui thread.
http://developer.android.com/reference/java/lang/Thread.html
http://docs.oracle.com/javase/tutorial/essential/concurrency/sleep.html
You will get ANR
If you implement Thread or HandlerThread, be sure that your UI thread does not block while waiting for the worker thread to complete—do not call Thread.wait() or Thread.sleep().
http://developer.android.com/training/articles/perf-anr.html
Also check the topic under How to Avoid ANRs