1

I really wonder why my application is working as usual buy LogCat generated error as below:

12-04 22:10:56.659: E/WindowManager(837): Activity kids.iq.kidsiqpicturesquestion.animal_q_hard_4 has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40a3d130 that was originally added here
12-04 22:10:56.659: E/WindowManager(837): android.view.WindowLeaked: Activity kids.iq.kidsiqpicturesquestion.animal_q_hard_4 has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40a3d130 that was originally added here
12-04 22:10:56.659: E/WindowManager(837):   at android.view.ViewRoot.<init>(ViewRoot.java:288)
12-04 22:10:56.659: E/WindowManager(837):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:249)
12-04 22:10:56.659: E/WindowManager(837):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193)
12-04 22:10:56.659: E/WindowManager(837):   at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118)
12-04 22:10:56.659: E/WindowManager(837):   at android.view.Window$LocalWindowManager.addView(Window.java:532)
12-04 22:10:56.659: E/WindowManager(837):   at android.app.Dialog.show(Dialog.java:269)
12-04 22:10:56.659: E/WindowManager(837):   at kids.iq.kidsiqpicturesquestion.animal_q_hard_4.onBackPressed(animal_q_hard_4.java:5462)
12-04 22:10:56.659: E/WindowManager(837):   at android.app.Activity.onKeyUp(Activity.java:2050)
12-04 22:10:56.659: E/WindowManager(837):   at android.view.KeyEvent.dispatch(KeyEvent.java:2485)
12-04 22:10:56.659: E/WindowManager(837):   at android.app.Activity.dispatchKeyEvent(Activity.java:2280)
12-04 22:10:56.659: E/WindowManager(837):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1649)
12-04 22:10:56.659: E/WindowManager(837):   at android.view.ViewRoot.deliverKeyEventPostIme(ViewRoot.java:2895)
12-04 22:10:56.659: E/WindowManager(837):   at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2868)
12-04 22:10:56.659: E/WindowManager(837):   at android.view.ViewRoot.handleMessage(ViewRoot.java:2048)
12-04 22:10:56.659: E/WindowManager(837):   at android.os.Handler.dispatchMessage(Handler.java:99)
12-04 22:10:56.659: E/WindowManager(837):   at android.os.Looper.loop(Looper.java:132)
12-04 22:10:56.659: E/WindowManager(837):   at android.app.ActivityThread.main(ActivityThread.java:4123)
12-04 22:10:56.659: E/WindowManager(837):   at java.lang.reflect.Method.invokeNative(Native Method)
12-04 22:10:56.659: E/WindowManager(837):   at java.lang.reflect.Method.invoke(Method.java:491)
12-04 22:10:56.659: E/WindowManager(837):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
12-04 22:10:56.659: E/WindowManager(837):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
12-04 22:10:56.659: E/WindowManager(837):   at dalvik.system.NativeStart.main(Native Method)

I do appreciated for your kindly help.

Erik
  • 935
  • 11
  • 28
SopheakVirak
  • 961
  • 6
  • 14
  • 36

4 Answers4

1

Quoting this answer: "You're trying to show a Dialog after you've exited an Activity.". It comes down to the problem that after the activity is finished (either by calling finish() or using the back button (which is the case here)), you try to show a dialog on top of the activity, which does not exist anymore. That is not possible.

Community
  • 1
  • 1
Jeffrey Klardie
  • 3,020
  • 1
  • 18
  • 23
  • @jefferey Klardie, I understand what you mean. Wait I am testing it again. – SopheakVirak Dec 04 '13 at 15:29
  • @Jefferey Klardie, It's working fine now. Thank you so much. The problem is because I put this: i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); – SopheakVirak Dec 04 '13 at 15:31
1

It seems like the Dialog was started while Activity was changing. I.e. the window of the correct activity is not there when Dialog is to be displayed. Dialog is tied to the window of activity which started it.

Alexey A.
  • 1,389
  • 1
  • 11
  • 20
1

The line I would look at is:

12-04 22:10:56.659: E/WindowManager(837): at kids.iq.kidsiqpicturesquestion.animal_q_hard_4.onBackPressed(animal_q_hard_4.java:5462)

Most likely something in the function is causing the error. Try commenting the entire function and see if you still experience it.

Si8
  • 9,141
  • 22
  • 109
  • 221
1

This will show you the exception..

12-04 22:10:56.659: E/WindowManager(837): Activity kids.iq.kidsiqpicturesquestion.animal_q_hard_4 has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40a3d130 that was originally added here
12-04 22:10:56.659: E/WindowManager(837): android.view.WindowLeaked: Activity kids.iq.kidsiqpicturesquestion.animal_q_hard_4 has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40a3d130 that was originally added here

This is because you are displaying a dialog in a Activity..but here the Activity already finished so its giving you the exception..

kalyan pvs
  • 14,486
  • 4
  • 41
  • 59