Is it possible to have the app only open on the Dex display?

The example in the doc under “5 steps to run your app on a specific display” works, and I can run
moveTaskToBack(true)
to minimize the main Activity, but is it possible to just have one Activity, which opens on the Dex display?

EDIT: Simpler than moveTaskToBack is to not invoke setContentView:
//setContentView(R.layout.activity_main)

Hi,

You can choose in which display the app will launch using the code snippet below:

// Samsung DeX display
DisplayManager dm = (DisplayManager)getSystemService(Context.DISPLAY_SERVICE);
Display[] displays = dm.getDisplays("com.samsung.android.hardware.display.category.DESKTOP");
Display targetDisplay = displays[0];

// Phone display 
DisplayManager dm = (DisplayManager)getSystemService(Context.DISPLAY_SERVICE);
Display targetDisplay = dm.getDisplay(Display.DEFAULT_DISPLAY);

Please go through Code Lab - Build | Samsung Developers to know details about this.

Thank you.

Thanks, but the Code Lab link seems to use the targetDisplay to launch a different activity. I want to have my app launch only in the Dex display when it’s available.

Thanks for the step by step tutorial!