Presentations From a Service
For a while now, I have been saying that the only way to use the
class to display stuff on a TV/monitor/projector is through an
Presentation inherits from
Dialog. That is true.
Sometimes, I would say that the only way to display stuff on a TV/monitor/projector
is through an
Activity. That, as it turns out, is not true.
One Stack Overflow answer
my own Stack Overflow question
on the subject, and with the help of those SO contributors I eventually figured
out how to drive an external display without an
I wrapped that pattern up into a
PresentationService that I have added to
my CWAC-Presentation library.
PresentationService clones some of the logic from
to allow you to define a
View that will be shown on a
Window connected to the
Display object representing the external display.
The biggest limitation is that we have to use a
in turn requires the
SYSTEM_ALERT_WINDOW permission. This is a permission that I really
try to avoid, both as a developer and as a user. Ostensibly, it is there because otherwise
Service could draw over the main display without the user being aware of it. Perhaps
in the future, a
Service rendering to an external display might be able to avoid this permission or
switch to some alternate, less-scary permission.
I hope to cover the implementation of
PresentationService in the next update to
my book. If you simply want to use it, the project
for using it, and there is a dedicated sample project
showing how to use it.
Learn second-generation Android app development — with Kotlin and the Android Jetpack — through CommonsWare’s Android app development training!