Display Progress bar while delay? Code Answer

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

Related Posts

© No Copyrights, All Questions are retrived from public domain.
Tutorial Guruji