Issue
When using the Android TV (1080p) 29API virtual device I've found that the KEYCODE_DPAD_CENTER
KeyEvent
is never fired. It also doesn't cause a button click event to fire either.
override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
if (event != null) {
when (event.keyCode) {
// This first match is never hit
KeyEvent.KEYCODE_DPAD_CENTER -> Log.d("DPAD", "Center")
// The rest of these all work fine
KeyEvent.KEYCODE_DPAD_UP -> Log.d("DPAD", "UP")
KeyEvent.KEYCODE_DPAD_DOWN -> Log.d("DPAD", "DOWN")
KeyEvent.KEYCODE_DPAD_RIGHT -> Log.d("DPAD", "RIGHT")
KeyEvent.KEYCODE_DPAD_LEFT -> Log.d("DPAD", "LEFT")
}
}
return super.dispatchKeyEvent(event)
}
Solution
The only way I solved this was by using a physical Android TV device for debugging. Hopefully this will save some of you the amount of time I wasted dealing with the emulator before I decided to just use a real TV.
Answered By - Stephen Gilboy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.