8

I got hundreads of error reports from my app and all of them is the same. It is really annoying because in my test devices (HTC Wildfire, Galaxy S I-II-III, Galaxy Mini, Galaxy Tab 10) this error NEVER occured, neither to me or my test buddy, looks like users do something different then us.

Because of this i cant give you too much information about the situation, there is one thing i see, it is something with a dialog's dismiss, which i actually never calls by code.

here is the error:

java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:587)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:324)
at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:151)
at android.app.Dialog.dismissDialog(Dialog.java:328)
at android.app.Dialog$1.run(Dialog.java:119)
at android.app.Dialog.dismiss(Dialog.java:313)
at android.app.Dialog.cancel(Dialog.java:1113)
at hu.kulcssoft.ingyenkonyv.reader.Reader$JavaScriptInterface$1.run(Reader.java:199)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

Can somebody help me? I got 30-40 error reports weekly because of this issue and i really cannot figure out why this is happening.

All suggestions will be appreciated. Thanks,

Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222
  • 2
    it looks like you are closing a dialog after any background work has been completed but that activity does not exist like in case of rotation so need proper check like context is null there dilaog is showing and more...... – Dheeresh Singh Jun 28 '12 at 14:38
  • 1
    My wild guess is your activity is finished before the dialog is dismissed.. – Ron Jun 28 '12 at 14:43
  • So is it solve the problem if i dismiss it in onFinish or in onDestroy like userSeven7s said ? – Adam Varhegyi Jun 29 '12 at 06:34

2 Answers2

13

Dismiss the dialog in your onFinish or onDestroy of the launching activity.

Or/And

Don't let your activity handle the orientation changes.

You might find some help in these answers : java.lang.IllegalArgumentException: View not attached to window manager

Community
  • 1
  • 1
Ron
  • 24,175
  • 8
  • 56
  • 97
  • What if i do it in onPause? It is the first that runs before onFinish and onDestroy. But thanks your advice anyway, i could only accept it as an answer if i update my app and the errors will not come anymore :) Maybe a week or so. – Adam Varhegyi Jun 29 '12 at 06:34
  • Prior to Android 4.1 the lockscreen can change orientation even if the activity doesn't support that and the lockscreen is just layer ontop of your activity. When you view it (prior to 4.1) your activity already receives onResume :| – RelativeGames Apr 24 '13 at 03:49
1
 @Override
            public void onConfigurationChanged(Configuration newConfig) {
                // TODO Auto-generated method stub
                super.onConfigurationChanged(newConfig);
                YourProgressDialog.dismiss();
            }

and Similarly you can use it on the onFinsh() and OnDestroy() or OnBackPressed() of the activity Depending on the Context of error.

Spry Techies
  • 896
  • 6
  • 21