0

My ProgressDialog is as follows :

ProgressDialog loading;

in AsyncTask :

       @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;
        }

My logcat :

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.

So, what is wrong here ? How can I get rid from the error in logcat ?

Noor Hossain
  • 1,620
  • 1
  • 18
  • 25

2 Answers2

2

I saw someone say it might be the device issue and you can ignore it. I have been searching for hours and at this point as long as the error does not crash the device you can ignore it

0

As mentioned by @Ditso K, this will occur only on some devices. But if you still want to remove the error from the logical, you can try this:

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

All you have to do is to add the constructor and provide the activity for the ProgressDialog. This will remove the error.

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
  • Can you please also mention the exact cause of the problem? – Ashish Neupane Feb 05 '22 at 09:59
  • 1
    this is happening because async task does not have any view as it runs in background. when you pass this, it refers to the sync task and you can use the progress dialog because any task extends context.It does not have any view. So this error is occurred. According to me it should occur every time but I don't know why does it happen only sometime. – Sambhav Khandelwal Feb 05 '22 at 10:18