The following warning message arises on API 23, 24 or 25 devices on device orientation changes from Portrait to Landscape (and vice versa) while the the Settings (options menu) is open. In both cases I have this error message in my log:
E/WindowManager: android.view.WindowLeaked: Activity com.example.test.myapplication.MainActivity has leaked window android.widget.PopupWindow$PopupDecorView{6bb10b1 V.E...... ......ID 0,0-686,168} 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.widget.PopupWindow.invokePopup(PopupWindow.java:1258) at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:1110) at android.support.v7.widget.AppCompatPopupWindow.showAsDropDown(AppCompatPopupWindow.java:105) at android.support.v4.widget.PopupWindowCompatKitKat.showAsDropDown(PopupWindowCompatKitKat.java:30) at android.support.v4.widget.PopupWindowCompat$KitKatPopupWindowImpl.showAsDropDown(PopupWindowCompat.java:129) at android.support.v4.widget.PopupWindowCompat.showAsDropDown(PopupWindowCompat.java:206) at android.support.v7.widget.ListPopupWindow.show(ListPopupWindow.java:722) at android.support.v7.view.menu.StandardMenuPopup.tryShow(StandardMenuPopup.java:160) at android.support.v7.view.menu.StandardMenuPopup.show(StandardMenuPopup.java:187) at android.support.v7.view.menu.MenuPopupHelper.showPopup(MenuPopupHelper.java:290) at android.support.v7.view.menu.MenuPopupHelper.tryShow(MenuPopupHelper.java:175) at
...
I saw some questions here, on SO, but it seems to me that everyone just took the workaround and have overridden onStop()
or onBackPressed()
in main activity.
To test and debug, I have created a simple project with the AS wizard (with Navigation Drawer Activity option activated, so there is an Options Menu already incorporated). The only thing added/changed was:
android:configChanges="orientation|keyboardHidden"
in the manifest
file, but I am still having the same warning.