Back to top

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-set-up.png

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.

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.

  1. Create the EnterpriseDeviceManager object.

  2. Create the DeXManager object.

  3. Call setDeXDisabled to true or false. This API requires the permission com.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

  1. Create the EnterpriseDeviceManager object.

  2. Create the DeXManager object.

  3. 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); 
    
  1. Create the CustomDeviceManager 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. this API requires the permission com.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

  1. Create the CustomDeviceManager 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 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

  1. Create the EnterpriseDeviceManager object.

  2. Create the DeXManager object.

  3. Call enforceEthernetOnly and set to true or false. This API requires the permission com.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

  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 the CustomDeviceManager 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);
    }
    

Is this page helpful?