瑞芯微RK3576开发板Android14三屏异显开发教程

本文介绍瑞芯微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

触觉智能RK3576鸿蒙开发板,

相关推荐
奋飞安全10 小时前
别被外壳骗了,那只是柔软的伪装 - 某小说App Token算法分析
android·逆向
这个杀手不太累11 小时前
Android 通过广播监听home键和任务键
android·广播·home键·任务键
MonkeyKing_sunyuhua11 小时前
python线程间怎么通信
android·网络·python
芦半山12 小时前
穿越二十年:Android Native 内存泄漏检测的进化之路
android
恋猫de小郭13 小时前
Flutter 在 iOS 26 模拟器跑不起来?其实很简单
android·前端·flutter
尤老师FPGA13 小时前
使用ZYNQ芯片和LVGL框架实现用户高刷新UI设计系列教程(第三十二讲)
android·java·ui
叫我龙翔13 小时前
【MySQL】从零开始了解数据库开发 --- 复合查询
android·mysql·数据库开发
Kapaseker14 小时前
Compose 中实现凸角、凹角、切角、尖角
android·kotlin
Erwinl14 小时前
android 开机启动 无线调试
android
此生只爱蛋14 小时前
mysql_store_result
android·adb