detect tv remote keys andoid studio

Solutions on MaxInterview for detect tv remote keys andoid studio by the best coders in the world

showing results for - "detect tv remote keys andoid studio"
Leon
03 Mar 2018
1@Override
2public boolean onKeyDown(int keyCode, KeyEvent event) {
3    Log.d("debug", "we are here");
4    switch (keyCode) {
5        case KeyEvent.KEYCODE_DPAD_UP:
6        case KeyEvent.KEYCODE_DPAD_DOWN:
7        case KeyEvent.KEYCODE_DPAD_RIGHT:
8        case KeyEvent.KEYCODE_DPAD_LEFT:
9        case KeyEvent.KEYCODE_BACK:
10        case KeyEvent.KEYCODE_ESCAPE:
11            Log.d("OnKey", "key pressed!");
12            Toast.makeText(MainActivity.this, "key pressed!", Toast.LENGTH_SHORT).show();
13            return true;
14    }
15    return false;
16}