瑞芯微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鸿蒙开发板,

相关推荐
Libraeking2 小时前
破壁行动:在旧项目中丝滑嵌入 Compose(混合开发实战)
android·经验分享·android jetpack
市场部需要一个软件开发岗位3 小时前
JAVA开发常见安全问题:Cookie 中明文存储用户名、密码
android·java·安全
JMchen1234 小时前
Android后台服务与网络保活:WorkManager的实战应用
android·java·网络·kotlin·php·android-studio
crmscs5 小时前
剪映永久解锁版/电脑版永久会员VIP/安卓SVIP手机永久版下载
android·智能手机·电脑
localbob5 小时前
杀戮尖塔 v6 MOD整合版(Slay the Spire)安卓+PC端免安装中文版分享 卡牌肉鸽神作!杀戮尖塔中文版,电脑和手机都能玩!杀戮尖塔.exe 杀戮尖塔.apk
android·杀戮尖塔apk·杀戮尖塔exe·游戏分享
机建狂魔5 小时前
手机秒变电影机:Blackmagic Camera + LUT滤镜包的专业级视频解决方案
android·拍照·摄影·lut滤镜·拍摄·摄像·录像
hudawei9965 小时前
flutter和Android动画的对比
android·flutter·动画
lxysbly7 小时前
md模拟器安卓版带金手指2026
android
儿歌八万首8 小时前
硬核春节:用 Compose 打造“赛博鞭炮”
android·kotlin·compose·春节
消失的旧时光-194310 小时前
从 Kotlin 到 Dart:为什么 sealed 是处理「多种返回结果」的最佳方式?
android·开发语言·flutter·架构·kotlin·sealed