Working with GuidedStepFragments on Android TV

If you want to develop for Android TV and easily adhere to TV UI best practices then the Leanback support library is your best bet.

The recently released support libraries revision 23.2.0 added new functionality to the GuidedStepFragment to further help direct users through a series of decisions in order to accomplish a goal. So what changed ?

Get the sample project on Github from here.

Button actions.

Button actions where added to GuidedActions. The idea is to make it faster to confirm/submit an action without having to scroll down through all the other actions before you can continue with your decision making. The videos below might explain this better.

Before:

Now:

In-order to create a button action , you can overide the onCreateButtonActions method or use GuidedStepFragment.setButtonActions. You can then listen for the selected button by overriding onGuideActionClicked.

 

Editable description fields.

 

It’s now possible to input text in an action. I would not overuse this feature though on TV , ever tried entering your email on TV with a remote ? Use GuidedAction.Builder.descriptionEditable(true) to make your action editable. You can listen for completion on this field via onGuidedActionEditedAndProceed. I saw they also added GuidedAction.Builder.descriptionInputType . I cant seem to make it work with the default TV keyboard on an Android TV emulator though.

Guided Action SubActions

This has the fill of drop down lists to it. So yeah we have these now. All you need to do is use the GuidedAction.Builder.subActions method to add more ‘sub’ actions to your main action. You can listen for a selection on any one of your subactions by overiding GuidedStepFragment.onSubActionClicked.

 

GuidedDatePickerAction

Simply put , this is just a date picker within the action view, yay. Just like editable GuidedActions. You listen for completion from within the onGuidedActionEditedAndProceed method.

As is clearly evident. Theres a lot of  new features within this release. I have made a sample app to show how to implement these new actions within your app. Get the sample project on Github from here.

I’m sure I’ve missed a few. If any let me know in the comments below.

 

Android TV Dialog

The leanback library for Android TV introduced the concept of guided step fragments. These have an intuitive way of presenting prompts to a user. I made a simple class that uses a GuidedStepFragment to create a simple yes/no dialog for TV. check out the git repo below

https://github.com/ckurtm/TvDialog

Native:

Native Dialog

TV dialog:

TV Dialog