androidandroid-tvgoogle-tvd-pad

using remote control for android TV application


I'm developing an Android application for TV when I'm trying to test it in the real Android TV I can't navigate to any button or anything using the remote control buttons up, down, left, right.

I have searched about it and I found that I have to use (Enable D-pad Navigation ) but I don't know how to use this , I didn't find any code or tutorial for it My application is so simple. It makes dynamic layout beside each other and each layout has only one button and one recycle view.


Solution

  • By default Android implements basic D-Pad navigation inferred from the layout distribution. It works quite well if you use mostly lists or linear layouts.

    The key difference is that the views are on the focused state instead of selected, so if you are using custom background i.e. for buttons it may look like it is not working while in fact it is.

    You can try it out on an emulator using the cursor keys on the keyboard.

    Alternatively or if the inferred navigation does not work you can define the nextFocusUp, Down, Left and Right per view.

    It is all quite well explained on the official documentation: https://developer.android.com/training/tv/start/navigation.html