The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.
This book profiles many ways of getting content to a TV:
Presentationand related classes, for touchscreen-enabled devices that also happen to presently have a connection to an external display
RemotePlaybackClient, for use with devices like the Chromecast
It is entirely possible to create one app that can support all of these
modes from one code base, though you are constrained by the most limited
option. In this case,
RemotePlaybackClient is the most limited option, as its
API is designed to tell some external device to play some media, whereas the
other options can support comparatively arbitrary user interfaces rendered through
normal Android widgets.
In this chapter, we will review the
sample application. This app is designed to give the user a roster of
slide-based presentations to choose from, then deliver one of those presentations.
The presentation will appear on the external display (e.g., TV or projector), while
the presenter will be able to control the presentation either from a touchscreen-equipped
Android device or a remote control.
You should read the following chapters before this one:
Reading up on specific hardware, like the Amazon Fire TV, is a good idea but not as critical.
Before we get into discussing the implementation of Decktastic, we should first review what the app looks like and how it functions.
If you were to set up Decktastic on some test device and
run it, the first thing that you would see is a media browsing UI built from
leanback-v17 support library, showing you a roster of the available
presentations to choose from:
Figure 824: Decktastic Media Browser
This UI works fine on TVs and on tablets. On phones… it gets a bit cramped.
Tapping on a presentation selects it:
Figure 825: Decktastic Media Browser, With Selected Presentation
Tapping on the presentation again opens it up into a
ViewPager-based UI for
Figure 826: Decktastic Main UI, Showing Presentation and Open Overflow
However, who sees what depends a bit upon the available hardware:
ViewPager-based UI, but the audience (those looking at the external display) will, by default, just see the slides
To move through the slides, you can:
The preview of this section took that left turn at Albuquerque.