How to Stop musicplayer when I detach headphones?
<p>I want to stop the currently running MusicPlayer when the user unplugs the headphones (both wired &amp; bluetooth).</p>

<p>I came across sevral posts where use of:</p>

<pre><code>isWiredHeadsetOn(), isBluetoothA2dpOn()
</code></pre>

<p>is suggested.</p>

<p>But Android docs says isWiredHeadsetOn() is deprecated. What alternative should I use?</p>

<p>Thanks</p>
