static int progress; ProgressBar progressBar; int progressStatus = 0; Handler handler = new Handler(); //u onCreate: progress = 0; progressBar = (ProgressBar) findViewById(R.id.progressbar); progressBar.setMax(200); //---do some work in background thread--- new Thread(new Runnable() { public void run() { //-do some work here- while (progressStatus < 100) { progressStatus = doSomeWork(); //-Update the progress bar- handler.post(new Runnable() { public void run() { progressBar.setProgress(progressStatus); } }); } //---hides the progress bar--- handler.post(new Runnable() { public void run() { //---0 - VISIBLE; 4 - INVISIBLE; 8 - GONE--- progressBar.setVisibility(View.GONE); } }); } //---do some long running work here--- private int doSomeWork() { try { //---simulate doing some work--- Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } return ++progress; } }).start();