title: view.getViewTreeObserver().addOnGlobalLayoutListener leaks Fragment
body: <p>When I use the <code>GlobalLayoutListener</code> to see if the softKeyboard is opened or not the fragment is not garbageCollected anymore after it is destroyed.</p>
  
  <p>What I do:</p>
  
  <ul>
  <li>I remove the Listener in the <code>onDestroy()</code> of my Fragment</li>
  <li>I set the Listener to <code>null</code> in <code>onDestroy()</code></li>
  <li>I set the view that is observed to null in <code>onDestroy()</code></li>
  </ul>
  
  <p>Still leaks the fragment.</p>
  
  <p>Does anyone had a similar issue and knows a fix for it??</p>
  
  <p>My <code>onDestroy</code>:</p>
  
  <pre><code>   @Override
  public void onDestroy(){
      Log.d(TAG , "onDestroy");
  
      if(Build.VERSION.SDK_INT &lt; 16){
          view.getViewTreeObserver().removeGlobalOnLayoutListener(gLayoutListener);
      }else{
          view.getViewTreeObserver().removeOnGlobalLayoutListener(gLayoutListener);
      }
  
      view = null;
      gLayoutListener = null;
  
  
  
      super.onDestroy();
      }
  </code></pre>