Menu

Samsung DeX and Knox

On this page

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

How To

  1. 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; or TRUE 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.

  2. Show the on-screen keyboard on a device or tablet, even when the physical keyboard is being used in DeX dual mode.

    • getShowIMEWithHardKeyboard
    • setShowIMEWithHardKeyboard
  3. 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.
  4. 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.
  • 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.
DexManager

public int setHomeAlignment(int mode)

public int getHomeAlignment()

addURLShortcut(int x, int y, String title, String url, ComponentName component)

addURLShortcut(int x, int y, String title, String url, String imgName, ComponentName component, ParcelFileDescriptor imgFD)


removeURLShortcut(String url, in ComponentName component);

setForegroundModePackageList(int state, in List<String> pkgList);

List<String> getForegroundModePackageList();

 

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

In this section

Enable or disable Samsung DeX

You can enable or disable Samsung DeX with a single API: setDexDisabled.

  1. Create the EnterpriseDeviceManager object.
  2. Create the DeXManager object
  3. Call setDeXDisabled to trueor false.
//create the EnterpriseDeviceManager and DeXManager objects
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
DexManager mDexManager = edm.getDexManager();

// disable DeX mode
mDexManager.setDexDisabled(false);

NOTE – this API requires the permission com.samsung.android.knox.permission.KNOX_DEX.

Allow screen timeout change and then set default time out to 20 minutes

  1. Create theEnterpriseDeviceManager object.
  2. Create the DeXManager object
  3. Call allowScreenTimeoutChangeand 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); 

NOTE – this API requires the permission com.samsung.android.knox.permission.KNOX_DEX.

Set loading logo

  1. Create theCustomDeviceManager object.
  2. Create the DeXManager object
  3. Load in the custom boot image. This must be a png.
  4. Call setLoadingLogo with the file path.
//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);

NOTE – this API requires the permission com.samsung.android.knox.permission.KNOX_CUSTOM_DEX.

Add app shortcut in DeX mode home screen

  1. Create theCustomDeviceManager object.
  2. Create the DeXManager object.
  3. Get the package name.
  4. Call addShortcut Pass in the x and y position of the shortcut and the component.
//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);

NOTE – this API requires the permission com.samsung.android.knox.permission.KNOX_CUSTOM_DEX.

Enforce Ethernet only

  1. Create theEnterpriseDeviceManager object.
  2. Create the DeXManager object.
  3. Call enforceEthernetOnly and set to true or false.
//create the EnterpriseDeviceManager and DeXManager objects
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
DexManager mDexManager = edm.getDexManager();

// enforce Ethernet only
mDexManager.enforceEthernetOnly(true);

NOTE – this API requires the permission com.samsung.android.knox.permission.KNOX_DEX.

App align

  1. Create the CustomDeviceManager object.
  2. Create the DeXManager object.
  3. Call setHomeAlignment
  4. 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

  1. Create theCustomDeviceManager object.
  2. Create the DeXManager object.
  3. 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);
  }

Need more help?

For complete information on methods, classes, and implementation, see Samsung Knox SDK API references.