Android using intents to control media player?
<p>I want to send a broadcast (or is it an intent?) from my app that will go to the next track of a music player if something is playing, or play/pause, etc. Here is the code that I have so far: </p>

<pre><code>    final Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
    i.putExtra(Intent.EXTRA_KEY_EVENT, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
    context.sendBroadcast(i); 
</code></pre>

<p>However as far as I can tell from my testing this code snippet doesn't quite do anything. Btw I put this code into a function and call it from a background service, in case that's relevant. </p>

<p>So how can I get this functionality working? If it's not possible for some reason I'm open to suggestions for work-arounds and/or alternate solutions. </p>

<p>Much appreciated, thanks. </p>
