当前位置: 首页 > news >正文

湖北网站建设专家凡科网官网首页

湖北网站建设专家,凡科网官网首页,企业展厅设计网,chmod wordpress在各种产品脑洞大开的时代#xff0c;需求也是日益新异#xff0c;笔者最近开发了一套双屏异显app。现在做一些总结1.双屏异显第一种实现方式(官方提供的Presentation)Android 提供了一个叫 Presentation 类#xff0c;来实现第二屏#xff0c; 继承 Presentation 实现第二…在各种产品脑洞大开的时代需求也是日益新异笔者最近开发了一套双屏异显app。现在做一些总结1.双屏异显第一种实现方式(官方提供的Presentation)Android 提供了一个叫 Presentation 类来实现第二屏 继承 Presentation 实现第二屏相当于一个特殊的弹窗窗口(具体实现)public class DifferentDislay extends Presentation{public DifferentDislay(Context outerContext, Display display){super(outerContext,display);}Overrideprotected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.diffrentdisplay);}}引用//双屏显示DisplayManager mDisplayManager;//屏幕管理类Display[] displays;//屏幕数组mDisplayManager (DisplayManager)MainActivity.this.getSystemService(Context.DISPLAY_SERVICE);displays mDisplayManager.getDisplays(); //得到显示器数组DifferentDislay mPresentation new DifferentDislay(getApplicationContext(),displays[1]);//displays[1]是副屏mPresentation.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);mPresentation.show();所需权限注以上是以 Presentation 实现的双屏异显这种方式比较适合双屏独立操作没有交际的时候如果存在双屏同显或者两者之际要有一些数据同步后比较麻烦比如主屏播放适配 - 投影到第二屏上面这种方法不适用了因为涉及到适配同步显示还有主副屏幕都要启动一个播放器才能实现性能极大的浪费设备性能比较好还可以以这种方式实现如果设备性能不是很好使用这种方式后照成视频卡顿严重者可能解码失败照成视频无法播放等等一些列并发问题针对上面开启第二屏 双屏同显播放视频我在原来的基础上做了极大的改善可以避免启动两个播放器照成性能的浪费2.双屏异显(同显)实现方式相信做双屏异显的同胞们肯定看过来Presentation 的源码 源码中显示 Presentation 是继承与 Dialog 来实现的在文章的开头我也有提到过第二屏可以看作一个特殊的 Dialog 来实现在研究Presentation 源码的时候发现它是通过  Window w getWindow();  来获取了一个窗口做我们android 开发的都知道 Window是android 顶级窗口看到这里我在想为何自己不能直接去创建一个窗口然后获取屏幕数组放置在第二屏幕上呢往下看public void addPresentation(Context paramContext){Display display ((MediaRouter) paramContext.getSystemService(Context.MEDIA_ROUTER_SERVICE)).getSelectedRoute(2).getPresentationDisplay();this.secondDisplay display;if (display ! null) {this.windowManager (WindowManager) paramContext.createDisplayContext(display).getSystemService(Context.WINDOW_SERVICE);this.secondDisplayContext paramContext.createDisplayContext(this.secondDisplay);return;}}上述代码我们获取窗口管理器通过paramContext创建了第 paramContext.createDisplayContext(this.secondDisplay);  第二屏幕创建好第二屏幕以后我们去给第二屏屏幕添加一个viewpublic View addView(int paramInt){this.view View.inflate(this.secondDisplayContext, paramInt, null);this.layoutParams new WindowManager.LayoutParams(2003, 3, 3);if (Build.VERSION.SDK_INT 23) {this.layoutParams.type 2038;} else {this.layoutParams.type 2003;}this.windowManager.addView(this.view, this.layoutParams);return this.view;}这样我们的第二屏幕就已经完成只需要根据自己的需求创建一个布局调用addView方法添加进去把添加进去的view返回出去在主类中进行操作就解决了数据数据同步问题以下是完整代码public class HelpHandPresentation{private WindowManager.LayoutParams layoutParams;private Display secondDisplay;private Context secondDisplayContext;private View view;private WindowManager windowManager;public void addPresentation(Context paramContext){Display display ((MediaRouter) paramContext.getSystemService(Context.MEDIA_ROUTER_SERVICE)).getSelectedRoute(2).getPresentationDisplay();this.secondDisplay display;if (display ! null) {this.windowManager (WindowManager) paramContext.createDisplayContext(display).getSystemService(Context.WINDOW_SERVICE);this.secondDisplayContext paramContext.createDisplayContext(this.secondDisplay);return;}}public View addView(int paramInt){this.view View.inflate(this.secondDisplayContext, paramInt, null);this.layoutParams new WindowManager.LayoutParams(2003, 3, 3);if (Build.VERSION.SDK_INT 23) {this.layoutParams.type 2038;} else {this.layoutParams.type 2003;}this.windowManager.addView(this.view, this.layoutParams);return this.view;}public void presentationAddView(){this.windowManager.addView(this.view, this.layoutParams);}public void removeLayoutView(){this.windowManager.removeView(this.view);}}相当于一个工具类只复制到项目里可以直接使用以下是调用方式HelpHandPresentation helpHandPresentation new HelpHandPresentation();helpHandPresentation.addPresentation(context);View view helpHandPresentation.addView(layout);三行代码即可调用方便3.双屏异显还有一种方式是通过 投影来实现的每次投影都会弹提示框进行确认有一定的局限性(MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);有兴趣的可以看看 MediaProjectionManager 源码实现这里就在叙述了完结这篇文章呢作为一个开头后续笔者会针对这一模块 发布一套三方sdk方便大家使用节省开发时间欢迎业界各位同胞提一些好的意见我会总结归纳进行梳理更好的完善sdk的开发进度与工作有缘留个关注把文章来源: blog.csdn.net作者我居然是个凡人版权归原作者所有如需转载请联系作者。原文链接blog.csdn.net/g1998_7_9/article/details/111373249
http://www.zqtcl.cn/news/311806/

相关文章:

  • 创业园区网站建设wordpress对接公众号源码
  • 怎么设计公司的网站长沙seo结算
  • 参加网站建设项目人员保障体系镇江网站建设门户报价
  • 漯河网站优化景区网站建设方案
  • 辽宁智能网站建设价位wordpress 公司主题
  • zencart 网站入侵冲电气软件 网站建设
  • 在网上做黑彩网站会怎样wordpress自定义代码在哪里设置
  • 福州营销网站建设老品牌网站开通
  • 电子商务网站体系结构有哪些?网站开发规划书怎么写
  • 建设一个网站要多少钱建设银行信用卡卡网站首页
  • 百度推广效果怎样seo网上培训课程
  • 广州品牌网站建设 优美wordpress 跳转页面
  • 成都专业的网站建设制作公司哪家好m3u8视频可以永久保存吗
  • 上海做兼职的网站如何在凡科建设网站
  • 沙朗镇做网站公司企业管理咨询师是干什么的
  • 起名网站建设商汇通网站
  • 网站开发费税率是多少钱建设小网站教程
  • 企业制作网站服务物联网应用有哪些
  • 中国建设网站银行个人做网站要注意什么条件
  • 莆田哪里有学做网站的wordpress可视化函数
  • 网站规划书500字上海金融网站制作网站制作公司好
  • 郑州网站制做钓鱼网站的公司
  • 网站域名授权怎么做以鹦鹉做头像的网站
  • 后端开发网站做一些什么WordPress能做门户网吗
  • 石家庄市住房和城乡建设厅网站好的企业型网站模板下载
  • 哈尔滨快速建站公司推荐网站刷流量会怎么样
  • 网站开发 顺德做新闻微网站有哪些
  • 如何阿里巴巴网站做推广苏州高新区建设局网站管网
  • 个人网站设计构思做汽车保养的网站
  • 在什么网站可以接国外的模具做中英文网站是怎么做的