How to unregister MediaButtonReceiver onDestroy?
<p>iam using MediaButtonReciever in my Streaming service to listen handle head sets and different devices action 
i'm declaring it in Manifest like this</p>

<pre><code>   &lt;receiver android:name="android.support.v4.media.session.MediaButtonReceiver"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MEDIA_BUTTON" /&gt;
        &lt;/intent-filter&gt;
    &lt;/receiver&gt;
</code></pre>

<p>The actions works just fine as long as the app in the background
once the app is terminated if i clicked on any MediaButton it crashes as the media button with the following crash </p>

<pre><code>Fatal Exception: java.lang.RuntimeException: Unable to start receiver android.support.v4.media.session.MediaButtonReceiver: java.lang.IllegalStateException: Could not find any Service that handles android.intent.action.MEDIA_BUTTON or a media browser service implementation
</code></pre>

<p>the problem is the receiver keeps receiving even if the app is destroyed, now how can i unregister the receiver once the app close ?
i have tried audioManager.unregister(MediaButtonReciever) but its depreciated </p>