Is it possible in the Andro开发者_开发百科id framework to duplicate what is displayed on the main display (UI)?
I have a situation where I need to demonstrate my app to many people, and it would be easier to do if I can duplicate the screen contents to an external monitor/TV. I am not married to the idea of using the HDMI port, I would be happy doing this through Wi-Fi or Bluetooth or USB if need be. What I am looking for is to see if I can do something similar to what Windows does by default when a second monitor is connected.
I have been through the developer's documentation and haven't been able to find anything that would allow me to do this, but it would not be the first time I've missed something. Specifically I need to do this with an HTC Evo.
Your options are limited, mostly by your choice of device. The HTC EVO's HDMI port will only play back apps via the built-in Gallery application (videos and still photos).
You will need to use a "software projector" like Droid@Screen -- attach your EVO to a Android SDK-equipped notebook that is connected to a projector. Droid@Screen will display the EVO's screen on the notebook (and, from there, on the projector). However, the frame rate is limited to about 5-6 fps, due to limitations in the SDK tools that Droid@Screen leverages.
Or, get your hands on an HTC Droid Incredible, which supports composite output to TVs of anything on the main display via a special cable. The Samsung Galaxy Tab also supports this for anything that does not involve a SurfaceView
, based on my experimentation to date. Some versions of the Samsung Galaxy S also support this, at least to some extent.
Or, use a webcam.
Or, use an ELMO (basically a webcam designed for document or device projection).
You can write a UiCloningService in jni that exposes a JNI method to clone the display. Usually, as Android is based on Linux, it will use the Linux framebuffer technology to represent display devices as dev nodes under /dev/fb*
or /dev/graphics/fb*
, where '*'
can be 0,1,2,...
depending on number of display connected.
As your device already has an HDMI port, it would be exposed via /dev/graphics/fb1
, considering fb0
to be your default LCD display.
In the cloning service, you can then write to device attribute files created for the HDMI port under sysfs and, if the display driver of your device has implemented those features (which most probably would have, otherwise what point to have an external HDMI display), these features/functions in the driver will be responsible for cloning the Ui on your primary display to the secondary display.
But you would have to write the Ui cloning service in JNI.(usually device manufacturers provide such methods, if at all an Android SDK is provided by them for development on that particular device).
For eg., I have attached a UiCloningService.cpp that has a cloning JNI function for Android GingerBread on an OMAP3 platform below:
UiCloningService.cpp
精彩评论