working with android tv - english
TRANSCRIPT
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Working with Android TVPedro Vicente Gmez SnchezAndroid Expert at Karumi
[email protected]@pedro_g_sgithub.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Are we going to develop always for smartphones?
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
https://developer.android.com/tv/adt-1/index.html
Nexus Player
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Introduction.
First steps.
Thinking different.
BrowseFragment.
DetailsFragment.
SearchFragment.
Recommendations.
Without Leanback library.
Agenda
-
Pedro V. Gmez Snchez - [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 dont want to do something different.
Forget about touch your TV.
Introduction
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
First steps
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Add Leanback library to your project:
First steps
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
First stepsConfigure an Activity to use LEANBACK_LAUNCHER intent filter:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Thinking different:
Try to use your smartphone without touch it!
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Try to avoid the keyboard:
Thinking different
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Thinking differentAll the user experience is going to be related to the focus usage.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
You have a microphone, use it.
Thinking different
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Use the background, its a powerful tool.
Thinking different
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Use content recommendations.
Thinking different
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Leanback Library
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
BrowseFragment
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
DetailFragment
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
SearchFragment
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
How can I use these Fragments?
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
BrowseFragmentCreate your own Fragment and extend from Leanback BrowseFragment:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
BrowseFragmentConfigure your user interface to apply your application colors and icons:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
BrowseFragmentOnce you have loaded all the content, configure one ArrayObjectAdapter with your data:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
BrowseFragmentEach row is going to be represented with one ArrayObjectAdapter, one HeaderItem and one Presenter:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
BrowseFragmentConfigure your listeners to change your user interface when one element is selected or clicked.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
DetailsFragmentCreate your own Fragment and extend from Leanback DetailsFragment:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
DetailsFragmentConfigure DetailsFragment background to be updated when needed:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
DetailsFragmentShow detailed information using the same approach we use with BrowseFragment based on ArrayObjectAdapter:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
DetailsFragmentAdd actions if needed:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
SearchFragmentCreate your own Fragment and extend from Leanback SearchFragment:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
SearchFragmentTo be able to react to user clicks you have to configure a OnItemViewClickedListener instance:
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
SearchFragmentOverride 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.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Android PresentersAndroid 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.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
RecommendationsAndroid gives you the opportunity to show content recommendations to your users. This mechanism is based on classic Android notifications.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Without Leanback library
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Without Leanback libraryOne 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, youll 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.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Without Leanback library: FocusNextFocusX 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.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Without Leanback library: State List AnimatorsIf you want to improve how your users know whats 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.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Without Leanback library: Use focus programmaticallyUse getCurrentFocus() method to know which is the view with the focus and dont be afraid to change focusable attribute of your views to create a better user experience.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Without Leanback library: BackgroundsTo be able to provide more information to the user about the current context you can change the Activity/Fragment background.
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
https://www.github.com/pedrovgs/TuentiTV
Show me the code!
-
Pedro V. Gmez Snchez - [email protected] - @pedro_g_s - github.com/pedrovgs
Questions?