本文介紹瑞芯微RK3576平臺Android14系統三屏異顯開發的方法,使用觸覺智能EVB7608開發板演示,開發板板載雙千兆網口、HDMI2.1、Daul LVDS、HDMI IN、Type C(USB3.2)等豐富的顯示、通信與拓展接口,幫助企業提高產品開發效率,降低成本和設計風險。
異顯實現原理
通過Presentation對象指定不同的DisplayID,來創建三個不同的窗口顯示到三個顯示屏上實現異顯。
創建Presentation對象方法有三種:
1、直接指定DisplayID,創建Presentation對象;
2、通過MediaRouter獲取Presentation對象;
3、通過DisplayManager獲取Display對象→創建Presentation對象→調用Presentation的show函數;
代碼實現
第一步:使用MediaRouter來獲取當前選中的路由,并從中獲取Display對象,然后創建并顯示MyPresentation,代碼如下:
private void showSecondByMediaRouter(Context context) { MediaRouter mediaRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE); MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO); if (route != null) { Display presentationDisplay = route.getPresentationDisplay(); if (presentationDisplay != null) { presentation = new MyPresentation(context, presentationDisplay); presentation.show(); } } }
第二步:使用DisplayManager 來獲取可用的顯示器,并根據顯示器的數量顯示MyPresentation和MyPresentation2,代碼如下:
private void showSecondByDisplayManager(Context context) { DisplayManager mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); Display[] displays = mDisplayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION); if (displays != null) { if (displays.length >= 2) { presentation = new MyPresentation(context, displays[0]); presentation.show(); presentation2 = new MyPresentation2(context, displays[1]); presentation2.show(); } else { presentation = new MyPresentation(context, displays[displays.length - 1]); presentation.show(); } } }
第三步:使用 ActivityOptions來啟動新的活動,并指定要在外部顯示器上顯示的內容,代碼如下:
private void showSecondByActivity(Context context) { DisplayManager mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); Display[] displays = mDisplayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION); ActivityOptions options = ActivityOptions.makeBasic(); MediaRouter mediaRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE); MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO); if (route != null) { Display presentationDisplay = route.getPresentationDisplay(); options.setLaunchDisplayId(presentationDisplay.getDisplayId()); Intent intent = new Intent(MainActivity.this, MainActivity2.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent, options.toBundle()); } if (displays.length >= 2) { ActivityOptions options2 = ActivityOptions.makeBasic(); options2.setLaunchDisplayId(2); Intent intent = new Intent(MainActivity.this, MainActivity3.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent, options2.toBundle()); } }
三異顯測試測試
打開系統的觸摸劃線測試,運行修改為三顯的DualScreenDemo APK,點擊 Persentation DisplayManager來開啟三個窗口分別顯示在三個屏幕上。

從Dumpsys input中可以看到 兩個ELAN Touchscreen分別對應上了 displayId 0、1和 2。分別在三個觸摸屏上劃線,對應的觸摸屏分別在指定的屏幕上劃線有效。
產品介紹
觸覺智能RK3576開發板,型號IDO-EVB7608-V1。助力全國產高階應用!支持工業級攝像機高清圖像輸入與4K HDMI超清錄屏,賦能工控視覺、AIOT等場景;8核與6T高算力,流暢運行視頻、AI應用及多任務處理,兼顧低功耗與工業穩定性,全能型高階方案就選TA!
-
開發板
+關注
關注
26文章
6289瀏覽量
118049 -
三屏顯示
+關注
關注
0文章
5瀏覽量
7864 -
rk3576
+關注
關注
1文章
265瀏覽量
1546
發布評論請先 登錄
瑞芯微RK3576開發板Android14三屏異顯開發教程
評論