– Android TV app hands on Tutorial 6

ErrorActivity & ErrorFragment

ErrorFragment is one of another layouts supported by Leanback library.


New -> Java Class -> Name: ErrorActivity
* We don’t use layout file for showing ErrorActivity.

Basically, it just attaches 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, ErrorFragment will show Error message with images.


 * AOSP project, SpinnerFragment is also implemented to show loading animation. But I introduced a minimum implementation/usage of ErrorFragment here.

Source code is on github.


Sponsored Links

One response

Leave a Reply

Your email address will not be published.