Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Working with Android TV

Karumi
June 12, 2016
44

Working with Android TV

Slides used during the talk Working with Android TV

Karumi

June 12, 2016
Tweet

Transcript

  1. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Working with Android TV Pedro Vicente Gómez Sánchez Android Expert at Karumi [email protected] @pedro_g_s github.com/pedrovgs
  2. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    https://developer.android.com/tv/adt-1/index.html Nexus Player
  3. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    • Introduction. • First steps. • Thinking different. • BrowseFragment. • DetailsFragment. • SearchFragment. • Recommendations. • Without Leanback library. Agenda
  4. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    • Nexus Player supports API level 21 or higher. • Leanback library is really useful. Almost essential. • Easy to work with if you don’t want to do something different. • Forget about touch your TV. Introduction
  5. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    First steps Configure an Activity to use “LEANBACK_LAUNCHER” intent filter:
  6. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Thinking different: Try to use your smartphone without touch it!
  7. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Thinking different All the user experience is going to be related to the focus usage.
  8. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Use the background, it’s a powerful tool. Thinking different
  9. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    BrowseFragment Create your own Fragment and extend from Leanback BrowseFragment:
  10. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    BrowseFragment Configure your user interface to apply your application colors and icons:
  11. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    BrowseFragment Once you have loaded all the content, configure one ArrayObjectAdapter with your data:
  12. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    BrowseFragment Each row is going to be represented with one “ArrayObjectAdapter”, one “HeaderItem” and one “Presenter”:
  13. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    BrowseFragment Configure your listeners to change your user interface when one element is selected or clicked.
  14. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    DetailsFragment Create your own Fragment and extend from Leanback DetailsFragment:
  15. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    DetailsFragment Configure DetailsFragment background to be updated when needed:
  16. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    DetailsFragment Show detailed information using the same approach we use with BrowseFragment based on ArrayObjectAdapter:
  17. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    SearchFragment Create your own Fragment and extend from Leanback SearchFragment:
  18. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    SearchFragment To be able to react to user clicks you have to configure a OnItemViewClickedListener instance:
  19. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    SearchFragment Override some methods to perform your search and indicate the adapter you are going to use to show search information. Your fragment has to implement Leanback SearchResultProvider interface.
  20. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Android Presenters Android Presenters are the base of how your data is shown inside Leanback Fragments. You can use some widgets from Leanback library or create your own presenters.
  21. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Recommendations Android gives you the opportunity to show content recommendations to your users. This mechanism is based on classic Android notifications.
  22. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Without Leanback library One of the problems related to the Leanback usage is that all your applications are going to be really similar. If you want to do something different, you’ll have to use your imagination. Some interesting ideas: • Use the focus and selectors to give more information to the user. • State list animator is going to be your new best friend. • Some elements will have to be focusables and disable the focus on runtime could be needed. • Change your backgrounds with cool images to provide more context to the user.
  23. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Without Leanback library: Focus NextFocusX configuration is going to be really useful for your UI. RequestFocus xml label will provide you more flexibility. Remember to enable focusable in some of your views, default state is false in some views.
  24. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Without Leanback library: State List Animators If you want to improve how your users know what’s the elemen it selected and you are not using a Leanback widget, you can use state list animators to animate your widgets when one get or lose the focus.
  25. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Without Leanback library: Use focus programmatically Use “getCurrentFocus()” method to know which is the view with the focus and don’ t be afraid to change “focusable” attribute of your views to create a better user experience.
  26. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    Without Leanback library: Backgrounds To be able to provide more information to the user about the current context you can change the Activity/Fragment background.
  27. Pedro V. Gómez Sánchez - [email protected] - @pedro_g_s - github.com/pedrovgs

    https://www.github.com/pedrovgs/TuentiTV Show me the code!