On my Android TV if I launch Pandora in the background and let music play, then launch my app. From my application if I press pause or next it receives these on my applicaiotn but also affects Pandora.
How can I prevent background applications from receiving these inputs. I tried obtaining audio focus which effectively stops the music but if button input is made again music will resume.
Any ideas?
Here is my code capturing remote inputs.
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((event.getSource() & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
switch (keyCode) {
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
moveToNextImage(true);
break;
case KeyEvent.KEYCODE_MEDIA_REWIND:
moveToPreviousImage(true);
break;
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
playPauseController();
break;
default:
break;
}
}
return super.onKeyDown(keyCode, event);