Customer Display

Double Screen Display Scheme for RK Platform

There are two ways of dual screen displaying: Android Presentation and RK dualscreen. We will focus on Android Presentation. Android Presentation is a dual-screen solution provided by Google, which implements the distribution of VOP at the View level. The logic is controlled on the same APP.

Introduction Android Presentation

Presentation is a class developed by Android for dual-screen display. It can be achieved in an APK, by giving Presentation a separate layout of view to achieve the same APK in the main screen and sub-screen display different view to achieve remarkable results. It works by calling the getDisplays method of DisplayManagerService to get the second display device. Pass the second display device as a parameter to Presentation, then implement its UI content in Presentation, and finally call the show method of Presentation to display the UI content on the second display device. The Imin models supporting dual screens are D1p-602, D1p-603, D1-502, D1-503, D1w-702, D1w-703, D4-502, D4-504 and D4-505

1. Introduction API

Official API and sample documentation:

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

Presentation is a special dialog type officially provided by Google for displaying specific content on other non-home screen displays. When it is created, it needs to bind the display screen and configure context and resource according to the target display screen and its size.

2.Binding Display

  • Obtain and bind through the MediaRouter interface

1
2
3
4
5
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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();
            }

3.Create Presentation

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
public class MyPresentation extends Presentation {
    /**
     * Rewrite constructor
     *
     * @param outerContext Context is not limited to Activity, it can also be Application Context or Service, etc.
     * @param display      Dislay of the secondary screen
     */
    public MyPresentation(Context outerContext, Display display) {
        super(outerContext, display);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.xxx);
        TextView textView = findViewById(R.id.text);
    }
}

4.Setting the secondary screen does not exit with the main screen

Usually Presentation is created to pass in the context of Activity, and the sub-screen will be displayed or hidden with the activity created to create a global sub-screen, which needs to add system pop-up window privileges to Presentation. As mentioned earlier, the context of the incoming Presentation can be Application or Service, provided that the system pop-up window permissions must be added, otherwise it will crash, so that Presentation can be newly created anywhere.

  • Add permissions to AndroidManifest.XML

1
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
  • Add code to Presentation

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: