这就是我创建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();
}
}
}
所以基本上在30秒后定时器结束后我想要对话,但它不能正常工作:(请帮助。
答案 0 :(得分:3)
您无法从非UI线程修改UI。使用handlers来执行此操作。
答案 1 :(得分:1)
稍微改变你的代码。像:
Runnable r = new Runnable()
{
public void run()
{
// TODO Auto-generated method stub
//dismiss your dialoge here....
}
};
你可以这样称呼:
Handler h = new Handler();
h.postDelayed(r, delayMillis);
答案 2 :(得分:0)