How to enter the dex mode with android app

Is there a way to enter dex mode using the Android app or command?
Miracast can show the entry screen by using android.settings.CAST_SETTINGS .
I wonder if there is a way to enter dex similarly to the above.
Is it possible to enter using
When I tried, a Permission Denial occurred and I couldn’t do it.


When a Samsung DeX compatible device is connected with a PC, user can switch into dex mode directly.

There are no proprietary Samsung APIs needed to launch apps in Samsung DeX, as it is enabled by default. Apps typically run as long as they adhere to Androids best coding practices.

Go through Samsung DeX guide to know how it works.

Thank you.