DeX minimize window programmatically?

When in DeX mode, is there a way for an application to minimize itself programmatically or is this only available via the minimize button in the app’s window frame?

First check the current mode of the app. If it is in dex mode then write the follwoing code to minimize the activity:

YourActivity.this.moveTaskToBack(true);

Original thread is HERE