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

相关推荐
Lei活在当下1 天前
【项目踩坑实录】并发环境下,Glide缓存引起的图片加载异常
android·debug·glide
my_power5201 天前
检出git项目到android studio该如何配置
android·git·android studio
三少爷的鞋1 天前
Repository 方法设计:suspend 与 Flow 的决选择指南(以朋友圈为例)
android
阿里云云原生1 天前
Android App 崩溃排查指南:阿里云 RUM 如何让你快速从告警到定位根因?
android·java
cmdch20171 天前
手持机安卓新增推送按钮功能
android
攻城狮20151 天前
【rk3528/rk3518 android14 kernel-6.10 emcp sdk】
android
何妨呀~1 天前
mysql 8服务器实验
android·mysql·adb
QuantumLeap丶1 天前
《Flutter全栈开发实战指南:从零到高级》- 25 -性能优化
android·flutter·ios
木易 士心1 天前
MVC、MVP 与 MVVM:Android 架构演进之路
android·架构·mvc
百锦再1 天前
国产数据库的平替亮点——关系型数据库架构适配
android·java·前端·数据库·sql·算法·数据库架构