MediaButtonReceiver not working with MediaBrowserServiceCompat
<p>I am trying to receive media button events from headsets or car controls (play/pause/etc.)</p>

<p>This is in my app manifest.</p>

<pre><code>&lt;service android:name=".mediaPlayerService.MediaPlayerService"
         android:exported="true"&gt;
    &lt;intent-filter&gt;
        &lt;action android:name="android.media.browse.MediaBrowserService"/&gt;
    &lt;/intent-filter&gt;
&lt;/service&gt;

&lt;!--
A receiver that will receive media buttons and send as
intents to your MediaBrowserServiceCompat implementation.
Required on pre-Lollipop. More information at
http://developer.android.com/reference/android/support/v4/media/session/MediaButtonReceiver.html
--&gt;
&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>This is part of my MediaPlayerService</p>

<pre><code>public class MediaPlayerService extends MediaBrowserServiceCompat {

@Override
public void onCreate()
{
    super.onCreate();
    initMediaSessions();
}

private void initMediaSessions()
{
    mSession = new MediaSessionCompat(getApplicationContext(), MediaPlayerService.class.getSimpleName());
    setSessionToken(mSession.getSessionToken());

    mSession.setCallback(new MediaSessionCompat.Callback()
                         {
                            //callback code is here.     
                         }            
    );
}

@Override
public int onStartCommand(Intent startIntent, int flags, int startId)
{
    if (startIntent != null)
    {
        // Try to handle the intent as a media button event wrapped by MediaButtonReceiver
        MediaButtonReceiver.handleIntent(mSession, startIntent);
    }
    return START_STICKY;
}
</code></pre>

<p>It seems like I'm missing something. When I press the pause button on my headset controls, the onStartCommand is never called.</p>

<p>Any idea why this is not working as expected?</p>