【问题标题】:ProgressDialog onProgressUpdate get error "DecorView: mWindow.mActivityCurrentConfig is null"ProgressDialog onProgressUpdate 得到错误“DecorView:mWindow.mActivityCurrentConfig 为空”
【发布时间】:2021-04-17 15:03:51
【问题描述】:

我的ProgressDialog如下:

ProgressDialog loading;

在异步任务中:

       @Override
        protected void onPreExecute() {
            super.onPreExecute();
            if(loading!=null&&loading.isShowing())
                loading.dismiss();
            loading = new ProgressDialog(mContext);
            loading.setCancelable(true);
            loading.setIndeterminate(false);
            loading.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            loading.setMax(100);
            loading.setTitle("DownLoading: ");
            loading.setMessage("Please Wait.... ");
            loading.show();
        }

       @Override
        protected void onProgressUpdate(final Integer... values) {
           // super.onProgressUpdate(values);
            String fileSize = "";
            double m = (double) lengthOfFile / (1024 * 1024);
            DecimalFormat dec = new DecimalFormat("0.00");
            fileSize = dec.format(m);//.concat(" MB");
            loading.setMessage("loading: " + fileSize + " MB");
            loading.setProgress(values[0]);

        }

        @Override
        protected Void doInBackground(String... strings) {

                  //(downloading code goes here .....) 

                publishProgress((int) ((total * 100) / lengthOfFile));

           return null;
        }

我的日志:

E/DecorView: mWindow.mActivityCurrentConfig is null
E/DecorView: mWindow.mActivityCurrentConfig is null
I/chatty: uid=10293(com.alquran.tafhimul_quran) identical 1 line
E/DecorView: mWindow.mActivityCurrentConfig is null
D/ViewRootImpl@ec670c4[DownLoading: ]: ViewPostIme key 0
E/DecorView: mWindow.mActivityCurrentConfig is null
D/ViewRootImpl@ec670c4[DownLoading: ]: ViewPostIme key 1
D/ViewRootImpl@ec670c4[DownLoading: ]: dispatchDetachedFromWindow
W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
D/InputTransport: Input channel destroyed: '465d15 ', fd=136
D/ViewRootImpl@bc87539[_StartActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@27432[_StartActivity]
D/InputMethodManager: getNavigationBarColor() -855310
E/ViewRootImpl: sendUserActionEvent() mView returned.

那么,这里有什么问题?如何摆脱 logcat 中的错误?

【问题讨论】:

  • this 可能相关
  • 我也面临同样的问题。你有解决方案吗?
  • @SagarMaiyad,没有兄弟。

标签: android android-asynctask progressdialog async-onprogressupdate


【解决方案1】:

我看到有人说这可能是设备问题,您可以忽略它。我已经搜索了几个小时,此时只要错误不会使设备崩溃,您就可以忽略它

【讨论】:

  • 感谢您的信息,只要我没有找到任何解决方案,这可能是公认的答案,Upvoted。
【解决方案2】:

正如@Ditso K 所述,这只会在某些设备上发生。但是如果你仍然想从逻辑中删除错误,你可以试试这个:

// add a constructor in your Async Task
public YourAsyncTask(MyMainActivity activity) {
    dialog = new ProgressDialog(activity);
}

您所要做的就是添加构造函数并为ProgressDialog 提供活动。这将消除错误。

【讨论】:

  • 能否请您提及问题的确切原因?
  • 发生这种情况是因为异步任务在后台运行时没有任何视图。当你传递这个时,它指的是同步任务,你可以使用进度对话框,因为任何任务都扩展了上下文。它没有任何视图。所以出现了这个错误。根据我的说法,它应该每次都会发生,但我不知道为什么它只会在某个时候发生。
  • 这个答案对你有帮助吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-21
  • 1970-01-01
相关资源
最近更新 更多