客显与副屏 ================= 1. 双屏幕显示方案 ++++++++++++++++++++++++++++++++++++++++++++++++ 双屏幕显示有两种方式:Android演示和RK DualScreen。 我们将专注于Android演示。 Android演示是Google提供的双屏幕解决方案,该解决方案在视图级别实现了VOP的分布。 该逻辑在同一应用程序上受到控制。 1.1 简介Android演示 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 演示文稿是由Android开发的,用于双屏幕显示。 可以在APK中实现它,通过给演示文稿单独的视图布局,以在主屏幕中实现相同的APK,并在子屏幕上显示不同的视图,以实现显着的结果。 它通过调用getDisplays的displayManagerService方法来获取第二个显示设备来起作用。 将第二个显示设备作为参数传递给演示文稿,然后在演示文稿中实现其UI内容,最后调用演示方法以在第二个显示设备上显示UI内容。 1.2 Introduction API ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **官方API和样本文档:** https://developer.android.com/reference/android/app/Presentation.html **Domestic documentation:** http://www.android-doc.com/reference/android/app/Presentation.html Source code & demo: `Link Customer Display demo downloads `_ 演示文稿是Google正式提供的特殊对话框类型,用于在其他非家庭屏幕显示器上显示特定内容。 创建时,它需要根据目标显示屏幕及其大小来绑定显示屏幕并配置上下文和资源。 1.3 Binding Display ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * Obtain and bind through the **MediaRouter** interface .. code-block:: java :linenos: :emphasize-lines: 1 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(); * Get and bind through the **DisplayManager** interface .. code-block:: java :linenos: :emphasize-lines: 1 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 = presentationDisplays[0]; Presentation presentation =new MyPresentation(context, presentationDisplay); presentation.show(); } 1.4 创建演示文稿 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. literalinclude:: ../code/Presentation.java :language: java :emphasize-lines: 1-17 :linenos: 1.5 设置辅助屏幕不会在主屏幕上退出 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 通常会创建演示文稿以在活动的背景下传递,并且将在创建的活动中显示或隐藏子屏幕,以创建一个全局子屏幕,该屏幕需要将系统弹出窗口特权添加到演示文稿中。 如前所述,如果必须添加系统弹出窗口权限,则可以是应用程序或服务的上下文,否则将崩溃,以便可以在任何地方新创建演示文稿。 * Add permissions to AndroidManifest.XML .. code-block:: java :linenos: :emphasize-lines: 1 * Add code to Presentation .. code-block:: java :linenos: :emphasize-lines: 1 getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); .. note:: The system bullet window privileges of the Presentation will cover the ordinary Presentation, causing it unable to display; please dismiss the global Presentation before displaying the ordinary secondary screen, in order to make the switching smooth, the following code is recommended: 1.6 Android 8.0 API添加了新的窗口类型 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Android 8.0 API为浮动窗口添加了一个窗口类型:TYPE_APPLICATION_OVERLAY 如果你的应用程序使用SYSTEM_ALERT_WINDOW权限,并试图使用以下窗口类型之一在其他应用程序和系统窗口上方显示提醒窗口: .. code-block:: xml :linenos: :emphasize-lines: 0 TYPE_PHONE TYPE_PRIORITY_PHONE TYPE_SYSTEM_ALERT TYPE_SYSTEM_OVERLAY TYPE_SYSTEM_ERROR TYPE_TOAST .. image:: ../images/CustomerDisplay/640.png :width: 800 这些窗口将始终显示在使用TYPE_APPLICATION_OVERLAY窗口类型的窗口下面。 如果应用程序是8.0版本,应用程序只能使用TYPE_APPLICATION_OVERLAY窗口类型来创建浮动窗口。(其他窗口类型在8.0中已弃用。) 2. D1/Falcon 1双屏显示方案 ++++++++++++++++++++++++++++++++++++++++++++++++ 2.1 Initialization of SDK calls ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Source code & demo: `Link demo downloads `_ 2.2 Binding Display ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^