android.view.WindowLeaked


#1

Hello guys, I have been following this book for a month now and currently in chapter 13(The Toolbar). I am having this really weird error as shown below:

E/WindowManager: android.view.WindowLeaked: Activity com.bignerdranch.android.criminalintent.CrimeListActivity has leaked window android.widget.LinearLayout{51f2bd3 V.E… …I. 0,0-0,0} that was originally added here
at android.view.ViewRootImpl.(ViewRootImpl.java:368)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:299)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
at android.support.v7.widget.TooltipPopup.show(TooltipPopup.java:84)
at android.support.v7.widget.TooltipCompatHandler.show(TooltipCompatHandler.java:155)
at android.support.v7.widget.TooltipCompatHandler.access$000(TooltipCompatHandler.java:39)
at android.support.v7.widget.TooltipCompatHandler$1.run(TooltipCompatHandler.java:53)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

This error happens whenever i press the Up button in the tool bar. Though the app does not crash, i feel quite uncomfortable seeing this in error logs. This also happens when i press the newly included delete button in CrimeFragment’s tool bar, but this time the first line of the error is different. shown below:

E/WindowManager: android.view.WindowLeaked: Activity com.bignerdranch.android.criminalintent.CrimePagerActivity has leaked window android.widget.LinearLayout{51f2bd3 V.E… …I. 0,0-0,0} that was originally added here…

I’ts now “CrimePagerActivity” and not “CrimeListActivity”. I’ve search on this error before coming here and got some similar cases on SO. The advice given was to put the “dismiss()” method in the onDestroy or onPause methods of the shown DialogClass(DatePickerFragment), which i did, but I’m still having this error. I’ll appreciate any help. Thanks.