Redman Redman - 4 months ago 58
Android Question

Display Progress bar while delay?

In my app i want to have a delay of 5 seconds and in this five seconds user should see progress dialog
i tried this

progressdialog.show();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}

progressdialog.dismiss();


but while Thread is sleeping the progessdialog also wont show .

Answer
 new CountDownTimer(6000, 1000) {
            public void onFinish() {
               mProgressDialog.dismiss();
              // my whole code
            }

            public void onTick(long millisUntilFinished) {
                mProgressDialog.show();
            }
        }.start();

This works fine

Comments