K2mini is a special self-service device, the two screens all could be set as main screen, you can refer the code below to adapt:
Double screen function:
We use class called :Presentation to implement the different display on the double screen:
First is the permission
Create a class to extend Presentation
public class TextDisplay extends Presentation
To get the second screen
public Display getPresentationDisplays() {
DisplayManager mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
displays = mDisplayManager.getDisplays();
for (int i = 0; i ‹ displays.length; i++) {
Log.e(TAG, “Screen” + displays[i]);
if ((displays[i].getFlags() & Display.FLAG_SECURE) != 0
&& (displays[i].getFlags() & Display.FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0
&& (displays[i].getFlags() & Display.FLAG_PRESENTATION) != 0) {
Log.e(TAG, “First real second screen” + displays[i]);
return displays[i];
}
}
return null;
}
Display the second screen
textDisplay=newTextDisplay(this,getPresentationDisplays());
textDisplay.show();
Remind:
If you want the main screen Activity to return to the desktop, the secondary screen View is still displayed, you can use the following code to complete:
getWindow()/*second screen
Window*/.setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
Note: When adding this type of Window to a normal application, you need to use the following code to apply for permission
if (!Settings.canDrawOverlays(this)) { Toast.makeText(this," 请同意显示窗口权限 ", Toast.LENGTH_SHORT).show(); startActivity(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)); }