PlaybackOverlayActivity & PlaybackOverlayFragment
– Android TV application hands on tutorial 7


PlaybackOverlayActivity & PlaybackOverlayFragment – Theory I will explain about only UI part in this chapter, video control is explained in next chapter. We will implement UI for handling video contents.   PlaybackOverlayActivity & PlaybackOverlayFragment – Implementation Creating PlaybackOverlayActivity & PlaybackOverlayFragment is the same way as in introduced previously. PlaybackOverlayActivity New → Activity → BlankActivity Activity Name: PlaybackOverlayActivity Layout Name: activity_playback_overlay  … This PlaybackOverlayActivity will refer activity_playback_overlay.xml file in res/layout folder. It is constructed in 2 layer – VideoView in the back and PlaybackOverlayFragment in the front. VideoView is the view which we will play video contents, and PlaybackOverlayFragment will show the UI for controlling video, which we will focus on in this […]

Continue reading →

– Android TV app hands on Tutorial 6


ErrorActivity & ErrorFragment ErrorFragment is one of another layouts supported by Leanback library. ErrorActivity New -> Java Class -> Name: ErrorActivity * We don’t use layout file for showing ErrorActivity. Basically, it just attaches ErrorFragment.

ErrorFragment New -> Java Class -> Name: ErrorFragment * We don’t use layout file for showing ErrorActivity. ErrorFragment class is a subclass of

Modify AndroidManifest.xml to declare ErrorActivity,

  Implement action to launch ErrorActivity I will change the name of item of GridItemPresenter “Item 1″ -> “ErrorFragment”, and I will launch this ErrorActivity by clicking this “ErrorFragment” item. Modify MainFragment, to launch ErrorActivity by intent.



Build and run By clicking “ErrorFragment” item, […]

Continue reading →

DetailsOverviewRowPresenter & FullWidthDetailsOverviewRowPresenter
– Android TV application hands on tutorial 5


[Update 2015.12.14: revise & add DetailsOverviewRowPresenter sample implementation, see bottom of this post.] Aim of this chapter – DetailsActivity implementation Implementing setOnItemViewClickedListener – onItemClicked callback function in MainFragment After implementation, we can click cards to go to next action. We show content detail information for each Movie item in this chapter. DetailsActivity, VideoDetailsFragment, and DetailsDescriptionPresenter DetailsActivity is invoked by clicking card in MainActivity. It shows VideoDetailsFragment, which is a layout to show card content. Implementing click listener in MainFragment To register a next action when user clicked certain card, we can use setOnItemViewClickedListener method defined in BrowseFragment class (MainFragment class is a sub class of BrowseFragment).  Sample implementation is as […]

Continue reading →

– Android TV application hands on tutorial 4


[Updated 2015.11.18]: Revise.[Updated 2016.3.13]: Updated wrong source code. Aim of this chapter Implementing background image update feature. Application was boring with no background, and it becomes much nice if it has appropriate background. Just setting background is easy, though, Android TV sample application explains how to dynamically change background linking with your current selection of contents. Before explanation of background change, I start explanation of onItemSelected callback function so that we get the event notification when the item is selected. Next, I will show simple background change implementation followed by better performance implementation using Picasso library. setOnItemViewSelectedListener listener & onItemSelected callback BrowseFragment supports to set listener when the itemview is selected & clicked. Current […]

Continue reading →

How to use Presenter and ViewHolder? – Android TV application hands on tutorial 3


[Update 2015.11.18]: Revise. Aim of this chapter In previous chapter, we looked GridItemPresenter. Its relationship was following. Presenter: GridItemPresenter ViewHolder’s view: TextView CardInfo/Item: String This was easy example. In this chapter, we proceed to introduce another type of Presenter, Presenter: CardPresenter ViewHolder’s view: ImageCardView CardInfo/Item: Movie class ImageCardView ImageCardView class is provided from Android SDK, and it provides a card design layout with main image, title text and content text. ImageCardView is a subclass of BaseCardView, so it is nice to look BaseCardView class. This is the explanation of BaseCardView, public class BaseCardView extends android.widget.FrameLayout A card style layout that responds to certain state changes. It arranges its children in a vertical column, […]

Continue reading →

Construction of BrowseFragment
– Android TV application hands on tutorial 2


[Update 2015.11.17: revise] Construction of BrowseFragment In this chapter, we will implement a combination of header and selectable objects (so called “cards”). But before going to real implementation, it’s good to understand the construction of BrowseFragment. You can also read the source code in the sdk (android/support/v17/leanback/app/) by yourself.  Let’s start explaination by using Android TV sample application. When you launch application, the contents are aligned in a grid structure. Each header title on the left have a each contents row, and this header – contents row relationship is one to one. This “header + contents row” combination is represented by ListRow. Body of BrowseFragment is a set of ListRow (I […]

Continue reading →