I am using the Android MediaRouter
(API 16) and Presentation
(API 17) classes to generate & manage a secondary display. I followed the example in ApiDemos to create unique non-mirrored output, and so far it works fine (testing with Nexus 10 connected to HDTV via HDMI cable).
Now, I have a situation where I want the Presentation object created in Activity X
to continue running on the secondary display, even if Activity X
invokes another Activity Y
. In this situation, Activity X
is still on the stack, but Activity Y
is now on top of it.
The problem is that when Activity Y
starts, the physical secondary display reverts to mirroring. When I exit Activity Y
, the content of Activity X's
Presentation goes back (since I never called dismiss()
on it).
So the question is: How can I keep a Presentation attached to a secondary display running on that display, even if a subordinate Activity is running on the local device?
UPDATE: One way I thought of doing this is to instantiate the Presentation
object from a background thread; then the subsequent creation of another Activity
should not interfere with the content being written by the background thread to its Presentation
object. But I'm not sure this will work, as it's generally not allowed to update a UI from a background thread.
Another approach would be to disable the use of secondary displays by the subordinate Activity
, if possible, thereby preventing it from reverting the secondary display to mirroring when the new Activity
becomes active. But I haven't found a way to do this either. Thanks again for any suggestions.