title: Rotating while PopupMenu is showing, gets android.view.WindowLeaked
body: <p>I have created a simple custom layout by extending <code>ViewGroup</code>. I create a <code>Button</code> and a <code>PopupMenu</code> on <code>init()</code>. If the button gets pressed, the <code>PopupMenu</code> gets shown. The problem is that, when the <code>PopupMenu</code> is showing, if I rotate the device, I get the following error message.</p>
  
  <blockquote>
    <p>E/WindowManager: android.view.WindowLeaked: Activity
    has leaked window
    android.widget.PopupWindow$PopupDecorView{c44e7da V.E...... ......ID
    0,0-392,960} that was originally added here</p>
  </blockquote>
  
  <p>I have found a similar question (<a href="https://stackoverflow.com/questions/13055479/popupmenu-popupwindowpopupviewcontainer-leak">PopupMenu PopupWindow$PopupViewContainer leak</a>), and the solution was calling <code>dismiss()</code> of the <code>PopupMenu</code> <code>onStop()</code>. However, since this is not an activity but a <code>ViewGroup</code>, I have no <code>onStop()</code>. So, I tried to find a similarly named event, and found <code>onDetachedFromWindow()</code>. I called <code>dismiss()</code> in <code>onDetachedFromWindow()</code>.</p>
  
  <p><code>onDetachedFromWindow()</code> does get called before screen rotation, but I still get the WindowLeaked error message.</p>
  
  <p>How can I solve this problem? Actually, it seems the application works fine and all I get is the error message in the log. Is this error ignorable?</p>