Android双屏机,副屏内容的显示和关闭

您所在的位置:网站首页 ipad主屏副屏怎么关闭 Android双屏机,副屏内容的显示和关闭

Android双屏机,副屏内容的显示和关闭

2024-07-15 01:09| 来源: 网络整理| 查看: 265

系统版本差异

Android N及以下版本,支持使用Presentation实现客显屏显示; Android O及以上版本,支持使用Activity实现客显屏显示。

副屏内容显示 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { //Android O开始,使用Activity显示客显屏内容 ActivityOptions options = ActivityOptions.makeBasic(); MediaRouter mediaRouter = (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE); MediaRouter.RouteInfo routeInfo = mediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO); if(routeInfo != null) { Display presentationDisplay = routeInfo.getPresentationDisplay(); options.setLaunchDisplayId(presentationDisplay.getDisplayId()); // 启动客显屏Activity Intent intent = new Intent(this, ViceScreenActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent, options.toBundle()); } } else { //Android N及以下版本,使用Presentation显示客显屏内容 MediaRouter mediaRouter = (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE); if(mediaRouter != null) { MediaRouter.RouteInfo routeInfo = mediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO); if(routeInfo != null) { Display presentationDisplay = routeInfo.getPresentationDisplay(); if(presentationDisplay != null) { //启动客显屏Presentation mPresentation = new Presentation(this, presentationDisplay); mPresentation.setContentView(R.layout.presentation_content); mPresentation.show(); } } } } 客显屏内容关闭

Android N及以下版本: mPresentation.dismiss();

Android O及以上版本: 将副屏Activity加入队列管理,调用finish();



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3