Reputation: 23404
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 .
Upvotes: 1
Views: 3511
Reputation: 1868
progressDialog.show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
}
},3000);
Upvotes: 1
Reputation: 23404
new CountDownTimer(6000, 1000) {
public void onFinish() {
mProgressDialog.dismiss();
// my whole code
}
public void onTick(long millisUntilFinished) {
mProgressDialog.show();
}
}.start();
This works fine
Upvotes: 3