美文网首页
Presentation简介

Presentation简介

作者: OkCoco | 来源:发表于2017-10-14 13:04 被阅读0次

简介

Presentation是一种在第二屏幕上进行内容显示的特殊Dialog,一个Presentation 在创建时就和一个 Display相关联,并根据Display的显示指标配置其上下文和资源配置。
值得注意的是,Presentation的Context是不同于它所包含的Activity所对应的Context的,使用Presentation自身的Context去渲染布局和加载资源是很重要的,因为他可以保证assets被以正确的尺寸和密度加载到目标Display。
当Display所依赖的窗口(或Activity)被移除时Presentation会自动Cancel,当Activity本身paused或resumed时,Activity应该保持pausing和resuming在Presentation中的播放内容。

选取Display

1.使用 MediaRouter

MediaRouter mediaRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
 MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute();
 if (route != null) {
     Display presentationDisplay = route.getPresentationDisplay();
     if (presentationDisplay != null) {
         Presentation presentation = new MyPresentation(context, presentationDisplay);
         presentation.show();
     }
 }

2.使用 DisplayManager
The display manager keeps track of all displays in the system. However, not all displays are appropriate for showing presentations. For example, if an activity attempted to show a presentation on the main display it might obscure its own content (it's like opening a dialog on top of your activity).
译文:DisplayManager保持跟踪系统中的所有显示。 但是,并非所有显示器都适合显示Presentation。 例如,如果Activity试图在主显示器上显示Presentation,它可能会掩盖其自己的内容(这就像在您的Activity之上打开一个Dialog)。

API的使用:

DisplayManager displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
 Display[] presentationDisplays = displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
 if (presentationDisplays.length > 0) {
     // If there is more than one suitable presentation display, then we could consider
     // giving the user a choice.  For this example, we simply choose the first display
     // which is the one the system recommends as the preferred presentation display.
     //考虑到多屏幕的存在,返回Display[]
     Display display = presentationDisplays[0];
     Presentation presentation = new MyPresentation(context, presentationDisplay);
     presentation.show();//Presentation本身就是Dialog
 }

相关文章

  • Presentation简介

    简介 Presentation是一种在第二屏幕上进行内容显示的特殊Dialog,一个Presentation 在创...

  • 学习 ApiDemos 012 Presentation

    简介 ApiDemos -> App -> Activity -> Presentation 源代码 http:/...

  • 【WPF】WPF介绍

    一、WPF简介 WPF:WPF即Windows Presentation Foundation,翻译为中文“Win...

  • Marp:Markdown制作PPT的利器

    一、简介 Marp,全称Markdown Presentation Ecosystem,是一件使用markdown...

  • 人脸识别攻防调研

    PA攻击(Presentation attacks)简介 攻击人脸识别系统就叫“PA攻击”,或PA。这种攻击有以下...

  • Vulkan 绘制与显示

    一、简介 Vulkan API最常用的用法就是用来绘制和显示图像(Presentation)。 但是因为支持Vul...

  • Presentation

    Helloeveryone, It was my pleasure to give presentation in...

  • presentation

  • A presentation

    Resently I got to be a little busy, and did not write the...

  • On Presentation

    1,用Presentation解决问题的沟通方式 2,Exucutive summary 故事是什么 如何解题 R...

网友评论

      本文标题:Presentation简介

      本文链接:https://www.haomeiwen.com/subject/fxfvyxtx.html