# 主屏activity内:
privateSecondDisplay secondDisplay;privatevoiddualScreen3288(){DisplayManager displayManager =(DisplayManager)getApplicationContext().getSystemService(DISPLAY_SERVICE);if(displayManager !=null){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.//多个附加屏时可自由选择,这里选第一个
secondDisplay =newSecondDisplay(this, presentationDisplays[0]);try{
secondDisplay.show();}catch(Throwable e){
e.printStackTrace();}}else{logError("showDualScreen: 未找到副屏!");}}}//关闭副屏privatevoidcloseSecondScreen(){if(secondDisplay !=null){
secondDisplay.release();
secondDisplay.dismiss();
secondDisplay =null;}}