1

I am creating a webview in my tv application and don't seem to be able to override the onKeyDown method when it comes to volume UP/DOWN. When i run it on an mobile or tablet emulator it works, but on the TV emulator or Android tv it doesn't do anything but control volume. Is there a way to override the volume control? I know i might be stupid to play with the volume actions, but they are the only free buttons on the remote, and sound isn't part of the application.

This is the section

@Override
public boolean onKeyDown(int keyCode, KeyEvent event){
    if(keyCode == KeyEvent.KEYCODE_VOLUME_UP){
        myMethod1();
        return true;
    } else if(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN){
        myMethod2();
        return true;
    }
    super.onKeyDown(keyCode, event);
    return true;
}
Daniel A
  • 11
  • 2

1 Answers1

0

I have the same problem. The Android TV system can't override volume controls. You have to launch countdown timers to know the volume and make action.

new CountDownTimer(time * 1000, 1000) { 
        public void onTick(long millisUntilFinished) {
        }
        public void onFinish() {
            int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
            ...
        }
    }.start();
Sergio
  • 21
  • 4