Samsung DeX and Knox
The Knox SDK provides information on how to use APIs to control Knox-enabled devices running in Samsung DeX.
About Samsung DeX
Samsung DeX is a new user experience that extends the functionality of your Android device to a desktop environment. Simply connect a compatible device to an HDMI monitor with the Samsung DeX Station or DeX pad, and it automatically launches.
Here is an illustration of this process when launched.
DeX APIs
Note, you must be using Knox 3.1 or greater to access the Samsung DeX APIs. Knox 3.0 and below do not have the Samsung DeX APIs built into the framework.
Class | Description |
DexManager | This class provides APIs to control the desktop mode (Dex) |
See the Samsung DeX overview for a full list of the APIs.
Knox 3.3
The Knox 3.3 SDK provides 4 new features to the Samsung DeX device: auto start, on-screen keyboard, open app on DeX display, and set custom wallpaper.
Prerequisites
All devices using these features must have the following minimum requirements:
- Knox v3.3
- Samsung HDMI to USB-C, DeX Pad, and DeX Station
Use the APIs
-
Automatically switch to Samsung Dual mode when a DeX device is connected
- setHDMIAutoEnterState
- getHDMIAutoEnterState
If this API is set to
FALSE
, Screen Mirroring is the default start up mode; orTRUE
and Dual Mode is enabled by default. To use DeX mode, the user can swipe down from the notification panel to turn their device into a keyboard or mouse. -
Show the on-screen keyboard on a device or tablet, even when the physical keyboard is being used in DeX dual mode.
- getShowIMEWithHardKeyboard
- setShowIMEWithHardKeyboard
-
Provide the menu option for users to automatically open the last app they were using when starting or exiting Samsung DeX. This will help the user to continue using an app when docking and undocking a device.
- allowAutoOpenLastApp
- isAutoOpenLastAppAllowed
Parameter
allowAutoOpenLastApp(True); allowAutoOpenLastApp(False); Result In this case, this method supersedes setForegroundModePackageList
and the apps’ behavior is dependent on how the user toggles this allowed setting feature.In the settings, this feature will appear greyed out, and the device user will be blocked from enabling it. To enable this feature, set the apps using the setForegroundModePackageList
API.Note: This API has a dependency on the setForegroundModePackageList API. For more information on foreground vs background apps on Samsung DeX, see the Samsung DeX developer guide. -
Set wallpaper for Samsung DeX while in dual mode.
- setWallpaper
This API supports the any format supported by the BitmapRegionDecoder.
Knox 3.2
Knox 3.2 adds the following new DeX APIs:
setHomeAlignment
: This API allows IT Admins to modify the way apps are aligned in DeX mode. For example, you can align apps in a preferred order. This functionality is perfect for organizations that want to set up numerous identical workstations throughout their organization.DexManager.addURLShortcut
– This API allows IT Admins to add a browser shortcut with a specific URL on the DeX home screen. This functionality is useful for enterprises that require users to access a URL frequently – for example, an internal Intranet network. A customized icon can also be displayed.
Knox 3.1
You use DeX APIs in the Knox 3.1 SDK to control features such as:
- Enable/disable Samsung DeX Mode
- Set Dex mode screen time out configuration
- allow/disallow screen time out change
- Enforce Ethernet only (block cellular data and WIFI)
- Check if a device is docked on the DeX station
- Disable apps in Dex mode
- Add/Remove application shortcut in Dex mode home screen
- Change Dex loading screen
- Use Ethernet MAC address with device dependent
Example business use case
Adopting Samsung DeX and controlling it with the Knox SDK allows you to capture a larger target audience. For example, you can add in features that further secure a banking app, such as controlling the screen timeout and enforcing a secure Ethernet data connection when the employee is plugged into the dock at work.
Examples
Enable or disable Samsung DeX
You can enable or disable Samsung DeX with a single API: setDexDisabled.
- Create the
object.EnterpriseDeviceManager
- Create the
DeXManager
object - Call
setDeXDisabled
totrue
orfalse
. This API requires the permissioncom.samsung.android.knox.permission.KNOX_DEX.
//create the EnterpriseDeviceManager and DeXManager objects EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context); DexManager mDexManager = edm.getDexManager(); // disable DeX mode mDexManager.setDexDisabled(false);
Allow screen timeout change and then set default time out to 20 minutes
- Create the
object.EnterpriseDeviceManager
- Create the
DeXManager
object - Call
allowScreenTimeoutChange
and set screen out time to true or false.
//create the EnterpriseDeviceManager and DeXManager objects EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context); DexManager mDexManager = edm.getDexManager(); // enable screentimeout mode mDexManager.allowScreenTimeoutChange(true); //set screen timeout in seconds CustomDeviceManager cdm = CustomDeviceManager.getInstance(); DexManager kcdm = cdm.getDexManager(); kcdm.setScreenTimeout(1200);
Set loading logo
- Create the
object.CustomDeviceManager
- Create the
DeXManager
object - Load in the custom boot image. This must be a png.
- Call
setLoadingLogo
with the file path. this API requires the permissioncom.samsung.android.knox.permission.KNOX_CUSTOM_DEX.
//create the Custom Device Manager and DeXManager objects CustomDeviceManager cdm = CustomDeviceManager.getInstance(); DexManager kcdm = cdm.getDexManager(); //Load in image and call setLoadingLogo ParcelFileDescriptor logoFD = ParcelFileDescriptor.open(new File(logoFile), ParcelFileDescriptor.MODE_READ_ONLY); kcdm.setLoadingLogo(logoFD);
Add app shortcut in DeX mode home screen
- Create the
object.CustomDeviceManager
- Create the
DeXManager
object. - Get the package name.
- Call
addShortcut
Pass in the x and y position of the shortcut and the component.com.samsung.android.knox.permission.KNOX_CUSTOM_DEX.
//create the Custom Device Manager and DeXManager objects CustomDeviceManager cdm = CustomDeviceManager.getInstance(); DexManager kcdm = cdm.getDexManager(); //get package name and call addShortcut with app x and y coordinates ComponentName component = new ComponentName("com.android.chrome", "com.google.android.apps.chrome.Main"); kcdm.addShortcut(0, 0, component);
Enforce Ethernet only
- Create the
object.EnterpriseDeviceManager
- Create the
DeXManager
object. - Call
enforceEthernetOnly
and set to true or false. This API requires the permissioncom.samsung.android.knox.permission.KNOX_DEX.
//create the EnterpriseDeviceManager and DeXManager objects EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context); DexManager mDexManager = edm.getDexManager(); // enforce Ethernet only mDexManager.enforceEthernetOnly(true);
App align
- Create the
object.CustomDeviceManager
- Create the
DeXManager
object. - Call
setHomeAlignment
- Specify the align type
- Custom order = VALUE_ORDER_CUSTOM
- Name(A-Z) = VALUE_ORDER_ALPHABETICAL
- Type =VALUE_ORDER_TYPE
CustomDeviceManager cdm = CustomDeviceManager.getInstance(); DexManager kcdm = cdm.getDexManager(); int mode = CustomDeviceManager.ALPHABETIC_GRID; kcdm.setHomeAlignment(mode);
Add URL shortcut to DeX home screen
- Create the
object.CustomDeviceManager
- Create the
DeXManager
object. - Call
addShortcut
and pass in the required parameters.
Parameters | Descriptions |
x | The x position of the URL shortcut. |
y | The y position of the URL shortcut. |
title | The Title of the URL shortcut. |
url | The URL address of the URL shortcut. |
component | The specific component to launch the URL shortcut. |
try { CustomDeviceManager cdm = CustomDeviceManager.getInstance(); DeXManager kcdm = cdm.getDeXManager(); String url = "http://www.naver.com"; ComponentName component = new ComponentName("com.android.chrome", "com.google.android.apps.chrome.Main"); kcdm.addURLShortcut(0, 0, "shortcut", url, component); } catch (SecurityException e) { Log.w(TAG, "SecurityException:" + e); }