I am trying to register a receiver using java and not the manifest, as I don't need this receiver work when my app is close.
If I use the manifest my receiver work well:
<receiver android:name=".services.PlayerService$RemoteControlReceiver" >
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
If I register it in my activity without the manifest, this don't work at all:
IntentFilter filter = new IntentFilter();
{
filter.addAction("android.intent.action.MEDIA_BUTTON");
}
registerReceiver(RemoteControlReceiver, filter);
I don't need to use the manifest, as I want to control the headset button only when my app is open.