Reputation: 435
This is how I am creating the PorgressDialog:
... progressBarDialog = new ProgressDialog( context );
progressBarDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressBarDialog.show(this, "Please Wait", "Updating your GPS coordinates",false,true);
//Trigger GPS service to update coordinates
fg.myOnresume(Name);
fg.dontSendSMS();
//Sets the timer at 30 secs
timer= new Timer();
timer.schedule(new startMapActivity());
}
class startMapActivity extends TimerTask
{
@Override
public void run()
{
//handler.sendEmptyMessage(0);
Log.d("", "StartMapActivty--->>>run()");
// Dismissing Dialog Box
if(progressBarDialog.isShowing())
{
progressBarDialog.dismiss();
}
}
}
So Basically after the the timer finished after 30sec I want to dimiss the Dialog, but it is not working :( Please help.
Upvotes: 2
Views: 3353
Reputation: 13390
change your code a bit. like:
Runnable r = new Runnable()
{
public void run()
{
// TODO Auto-generated method stub
//dismiss your dialoge here....
}
};
and you can call this like:
Handler h = new Handler();
h.postDelayed(r, delayMillis);
Upvotes: 1
Reputation: 40503
Check this thread : ProgressDialog dismissal in android
Upvotes: 0
Reputation: 43098
You can't modify UI from non UI thread. Use handlers to do it.
Upvotes: 3