0

How to Override the power key of an IR remote for a rooted Android device? I have tried the following

         case KeyEvent.KEYCODE_STB_POWER:
            Toast.makeText(this, "KEYCODE_STB_POWER key pressed",
                    Toast.LENGTH_SHORT).show();
            return true;

        case KeyEvent.KEYCODE_AVR_POWER:
            Toast.makeText(this, "KEYCODE_AVR_POWER key pressed",
                    Toast.LENGTH_SHORT).show();
            return true;

        case KeyEvent.KEYCODE_TV_POWER:
            Toast.makeText(this, "KEYCODE_AVR_POWER key pressed",
                    Toast.LENGTH_SHORT).show();
            return true;

        case KeyEvent.KEYCODE_POWER:
            Toast.makeText(this, "KEYCODE_POWER key pressed",
                    Toast.LENGTH_SHORT).show();
            return true;

But none of the above worked. Am I missing anything?

Code_Yoga
  • 2,968
  • 6
  • 30
  • 49

1 Answers1

0

Try logging the key so you get the actual KeyEvent to be treated. for example:

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    Log.d("keycode", "" + keyCode);
(...)
}
Neron T
  • 369
  • 2
  • 8