Customer Display
1. 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.
1.1 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 D1w-702, D3-504, D3-505, D3-506, D1w-703, D4-502, D4-504 and D4-505
1.2 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:
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.
1.3 Binding Display
Obtain and bind through the MediaRouter interface
1MediaRouter mediaRouter =(MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
2MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute();
3if(route !=null){
4 Display presentationDisplay = route.getPresentationDisplay(); if(presentationDisplay !=null){
5 Presentation presentation =new MyPresentation(context, presentationDisplay); presentation.show();
Get and bind through the DisplayManager interface
1DisplayManager displayManager =(DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
2Display[] presentationDisplays = displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
3if(presentationDisplays.length >0){
4 // If there is more than one suitable presentation display, then we could consider
5 // giving the user a choice. For this example, we simply choose the first display
6 // which is the one the system recommends as the preferred presentation display.
7 Display display = presentationDisplays[0];
8 Presentation presentation =new MyPresentation(context, presentationDisplay);
9 presentation.show();
10 }
1.4 Create Presentation
1public class MyPresentation extends Presentation {
2 /**
3 * Rewrite constructor
4 *
5 * @param outerContext Context is not limited to Activity, it can also be Application Context or Service, etc.
6 * @param display Dislay of the secondary screen
7 */
8 public MyPresentation(Context outerContext, Display display) {
9 super(outerContext, display);
10 }
11 @Override
12 protected void onCreate(Bundle savedInstanceState) {
13 super.onCreate(savedInstanceState);
14 setContentView(R.layout.xxx);
15 TextView textView = findViewById(R.id.text);
16 }
17}
1.5 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
1getWindow().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:
2. Double Screen Display Scheme for D1/D1 Pro/Falcon 1
Customers can refer to the demo and operating instructions below for docking
D1/D1 Pro/Falcon 1 ScreenSDK
1. Initialization of SDK calls
Function:sendLCDCommand
Remarks:Send LCD control commands
1void sendLCDCommand(int flag);
2transfer:ILcdManager.getInstance(this).sendLCDString(int flag)
parameter:
flag –> 1 initialization、2 Wake up LCD、3 hibernate LCD、4 clear screen
2. Send a string to display on Secondary screen
Function:sendLCDString
Remarks:Send a string to display on Secondary screen
1void sendLCDString(String string);
2transfer:ILcdManager.getInstance(this).sendLCDString(String string);
parameter:
string –> string The content of the displayed string can display up to 5 Chinese characters or 10 English characters
3. Send a multi-line secondary screen content string
Function:sendLCDMultiString
Remarks:Send a multi-line secondary screen content string
1void sendLCDMultiString(in String[] text, in int[] align);
2transfer: ILcdManager.getInstance(this).sendLCDMultiString(in String[] text, in int[] align);
parameter:
test –> The content of each line of the multi-line secondary screen, the content of each line can be empty, and only occupies space at this time align –> The weight of the content of each row of the secondary screen (0 left, 1 middle, 2 right)
4. Send double-line secondary screen content string
Function:sendLCDDoubleString
Remarks:Send double-line secondary screen content string
1void sendLCDDoubleString(String topText, String bottomText);
2transfer: ILcdManager.getInstance(this).sendLCDDoubleString(String topText, String bottomText);
parameter:
topText/bottomText –> String displayed on the secondary screen
5. Send a picture to display on the secondary screen
Function:sendLCDBitmap
Remarks:Send double-line secondary screen content string
1void sendLCDBitmap(in Bitmap bitmap)
2transfer: ILcdManager.getInstance(this).sendLCDBitmap(in Bitmap bitmap);
parameter:
bitmap –> bitmap The displayed image object, with a maximum size of 240*320 pixels
6. set font size
Function:setTextSize
Remarks:set font size
1void setTextSize(in size)
2transfer: ILcdManager.getInstance(this).setTextSize(in size);
parameter:
size –> size Do not set too small or too large font default 55