How can I send an orderedBroadcast to a specific receiver? I am broadcasting the ACTION_MEDIA_BUTTON and only want a specific app (Winamp for example) to receive it. I don’t want Pandora to steal it. Is there a way to explicitly define who the receiver will be?
void sendBroadcast() {
Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
synchronized (this) {
i.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, theKeyEvent));
ctx.sendOrderedBroadcast(i, null);
i.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, theKeyEvent));
ctx.sendOrderedBroadcast(i, null);
}
}
If you know the package of the Winamp application, you can use setPackage to restrict Intent resolution to only a specific package.