title: Android - MediaController leaking on activity
body: <p>I am using MediaPlayer and MediaController objects to stream audio.  When closing the activity  I am getting a window leaked exception.</p>
  
  <p>I have the following in my activity which doesn't help at all.</p>
  
  <pre><code>@Override
  protected void onStop() {
      super.onStop();
      mediaController.hide();
  
  }
  </code></pre>
  
  <p>I get the following stack trace:</p>
  
  <blockquote>
    <p>01-24 20:11:18.317: E/WindowManager(26286): Activity
    co.uk.ing_simmons.aberdeensoundsites.RecordingDetails has leaked
    window com.android.internal.policy.impl.PhoneWindow$DecorView@4182d590
    that was originally added here 01-24 20:11:18.317:
    E/WindowManager(26286): android.view.WindowLeaked: Activity
    co.uk.ing_simmons.aberdeensoundsites.RecordingDetails has leaked
    window com.android.internal.policy.impl.PhoneWindow$DecorView@4182d590
    that was originally added here 01-24 20:11:18.317:
    E/WindowManager(26286):   at
    android.view.ViewRootImpl.(ViewRootImpl.java:418) 01-24
    20:11:18.317: E/WindowManager(26286):     at
    android.view.WindowManagerImpl.addView(WindowManagerImpl.java:294)
    01-24 20:11:18.317: E/WindowManager(26286):   at
    android.view.WindowManagerImpl.addView(WindowManagerImpl.java:226)
    01-24 20:11:18.317: E/WindowManager(26286):   at
    android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:151)
    01-24 20:11:18.317: E/WindowManager(26286):   at
    android.view.Window$LocalWindowManager.addView(Window.java:547) 01-24
    20:11:18.317: E/WindowManager(26286):     at
    android.widget.MediaController.show(MediaController.java:470) 01-24
    20:11:18.317: E/WindowManager(26286):     at
    android.widget.MediaController.show(MediaController.java:429) 01-24
    20:11:18.317: E/WindowManager(26286):     at
    co.uk.ing_simmons.aberdeensoundsites.RecordingDetails$2.run(RecordingDetails.java:202)
    01-24 20:11:18.317: E/WindowManager(26286):   at
    android.os.Handler.handleCallback(Handler.java:615) 01-24
    20:11:18.317: E/WindowManager(26286):     at
    android.os.Handler.dispatchMessage(Handler.java:92) 01-24
    20:11:18.317: E/WindowManager(26286):     at
    android.os.Looper.loop(Looper.java:153) 01-24 20:11:18.317:
    E/WindowManager(26286):   at
    android.app.ActivityThread.main(ActivityThread.java:5006) 01-24
    20:11:18.317: E/WindowManager(26286):     at
    java.lang.reflect.Method.invokeNative(Native Method) 01-24
    20:11:18.317: E/WindowManager(26286):     at
    java.lang.reflect.Method.invoke(Method.java:511) 01-24 20:11:18.317:
    E/WindowManager(26286):   at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
    01-24 20:11:18.317: E/WindowManager(26286):   at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) 01-24
    20:11:18.317: E/WindowManager(26286):     at
    dalvik.system.NativeStart.main(Native Method) 01-24 20:11:18.325:
    E/InputEventReceiver(26286): channel '41c81858
    Panel:co.uk.ing_simmons.aberdeensoundsites/co.uk.ing_simmons.aberdeensoundsites.RecordingDetails
    (client)' ~ Publisher closed input channel or an error occurred. 
    events=0x9</p>
  </blockquote>
  
  <p>Which seems to point to line 202 which is this line:</p>
  
  <pre><code>mediaController.show();
  </code></pre>
  
  <p>I have been Googling this for hours now and literally everything says to put "mediaController.hide()" in the onStop method to prevent leaks.  Which clearly isn't working so any help or guidance here would be greatly appreciated.</p>
  
  <p>Thanks</p>