2017-04-04 553 views
-2

我正在创建Android应用程序中的虚拟显示。如何在Android上测试虚拟显示器?

DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); VirtualDisplay virtualDisplay = displayManager.createVirtualDisplay("Test Display", 1000 /* width /, 1000 / height */, DisplayMetrics.DENSITY_DEFAULT, null, DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION);

我怎样才能使这个显示器上的内容和验证?

我已经创建了一个演示演示文稿,试图加载一个webview,但没有看到任何应用程序屏幕的影响。

+0

任何人都可以建议什么是从这个问题缺少? –

回答

0
1. Permission Needed :- WRITE_EXTERNAL_STORAGE. 
2. Create MediaProjectionManager 
3. StartActivityForResult with createScreenCapture intent 
4. OnActivityResult create MediaProjection with callback 
5. Create ImageReader (Take PixelFormat RGBA_8888 as parameter) 
6. Register callbacks on ImageReader to capture screen shot. 
7. Create Virtual Display with ImageReader'surface 
8. Create DisplayListener to get callbacks on whenever new displays are added, removed or modified 
9. Register DisplayListener with DisplayManager 
10. OnDisplayChanged event of DisplayListener Create a presentation and show it 
11. Create a class for sample presentation which shows a layout 
12. When Presentation is shown, you get notification on onImageAvailable api of callback registered with ImageReader 

13.关于通知,从ImageReader捕获图像并将其保存到SD卡。

P.S: - 这个问题是我问的,我已经回答了我自己,请让我知道你是否需要关于这个问题和答案的更多细节。

+0

我想将汽车仪表板的头部单元投影到后座显示屏。我正在考虑使用这种虚拟显示技术。我在哪里可以找到更多与虚拟展示相关的文档或示例项目。如果你有任何链接,请给我。 @Vineet Setia –

相关问题