Android:无法关闭 ProgressDialog

标签 android progressdialog dismiss

这就是我创建 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 秒后完成后,我想关闭对话框,但它不起作用:(请帮忙。

最佳答案

您无法从非 UI 线程修改 UI。使用handlers去做这件事。

关于Android:无法关闭 ProgressDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5432077/

相关文章:

android - 房间 : How to automigrate DB for new table?

java - 如何将字符串值转换为 LatLng() 对象?

android - 如何将 DynamicLayout 锚定到 Canvas 底部?

android - AsyncTask 的进度对话框 - Android

java - ProgressDialog 停不下来

android - 本地化进度对话框

ios - 解除 UIActivityViewController 后的操作

ios - 尝试多种选项后无法关闭模态视图 Controller

java - 如何将 GPS 坐标发送到另一个类

ios - 关闭两个 View Controller 然后推送一个 View Controller - Swift