Create containers

NOTE: Dual Persona and Corporate Liable (CL) containers were deprecated on the Note 10 and later devices. COM containers were deprecated in S10s running Knox 3.3 and higher. For more information, see Unsupported COM and CL Workspaces. Deprecated container types that were created on existing devices in your fleet will continue to work until the official end of life (EOL) of the devices. However, we recommend that you use the new Device management modes to take advantage of the latest security and personal privacy features.

This topic shows how to create a Knox Platform for Enterprise container.

Create a container

To support the new container, EMM agents leverage Androids method to create a Work Profile. After a manged profile is created, simply activating a Knox license converts the profile to a Knox Workspace.

Here is a sample code snippet on provisioning a PO from our work profile sample app.

 // Provision an Android Profile Owner
    private void createAndroidProfile() {

        Activity provisioningActivity = this;
        // Set up the provisioning intent
        Intent provisioningIntent = new Intent("android.app.action.PROVISION_MANAGED_PROFILE");
        provisioningIntent.putExtra(EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,getPackageName());
        if (provisioningIntent.resolveActivity(provisioningActivity.getPackageManager()) == null) {
            // No handler for intent! Can't provision this device.
            // Show an error message and cancel.
        } else {
            // REQUEST_PROVISION_MANAGED_PROFILE is defined
            startActivityForResult(provisioningIntent, 1);
            provisioningActivity.finish();
        }
    }

Next, you activate a Knox license. This upgrades your Android work profile to a Knox Workspace. Here is an example:

private void activateLicence() {

        // Instantiate the EnterpriseLicenseManager class to use the activateLicense method
        KnoxEnterpriseLicenseManager klmManager = KnoxEnterpriseLicenseManager.getInstance(this);

        try {
            // ELM License Activation TODO Add license key to Constants.java
            klmManager.activateLicense(Constants.KLM_LICENSE_KEY);
            mUtils.log(getResources().getString(R.string.license_progress));

        } catch (Exception e) {
            mUtils.processException(e,TAG);
        }
    }

Remove container

When a Knox license is deactivated, the KPE container is locked. Here is an example:

private void deActivateLicence() {

        // Instantiate the EnterpriseLicenseManager class to use the activateLicense method
        KnoxEnterpriseLicenseManager klmManager = KnoxEnterpriseLicenseManager.getInstance(this);

        try {
            // License Activation TODO Add license key to Constants.java
            klmManager.deActivateLicense(Constants.KLM_LICENSE_KEY);
            mUtils.log(getResources().getString(R.string.deactivate_license_progress));

        } catch (Exception e) {
            mUtils.processException(e,TAG);
        }
    }
See Upgrade Android Work Profile to Knox Workspace for a full walk through of this process using a Knox sample app.

Customize tab names

Knox 3.2.1 introduced a tabbed UI view for the Personal and Workspace apps.

Knox 3.4 introduces customized names for the Personal and Workspace tabs, using the API setCustomResource().

Through new parameter values, you can set custom container resources like tab names.

In the sample code below, we change the name of the Personal tab to Out of Workspace:

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 try {
     Bitmap bitmap = // generate a Bitmap object from resource
     KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
     ContainerConfigurationPolicy ccp = kcm.getContainerConfigurationPolicy();
     Bundle data = new Bundle();
     data.putParcelable(KEY_IMAGE, bitmap);
     boolean result = ccp.setCustomResource(ContainerConfigurationPolicy.RES_TYPE_PROFILE_ICON, data);
	 Bundle data2 = new Bundle();
	 data2.putParcelable(KEY_NAME, "Out of Workspace");
	 boolean result2 = ccp.setCustomResource(ContainerConfigurationPolicy.RES_TYPE_PERSONAL_MODE_NAME, data2);
     if (true == result) {
         // set succeeded.
     } else {
         // set failed.
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }