Since: API level 7
public class

KnoxEnterpriseLicenseManager

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.license.KnoxEnterpriseLicenseManager

Class Overview

This class provides APIs to handle Knox Enterprise license (KLM license) on device.

Since
API level 7
KNOX 1.0.1

Summary

Constants
String ACTION_LICENSE_STATUS Broadcast Action : Sent to inform about result of Knox License activation, deactivation or validation.
int ERROR_ANOTHER_PROCESS_IN_PLACE Indicates that the calling package is already activating/deactivating a license key and must wait the result to try again.
int ERROR_INTERNAL Indicates that an unexpected error occurred during operation.
int ERROR_INTERNAL_SERVER Indicates that an unexpected error occurred in license server during operation.
int ERROR_INVALID_BINDING Either the application product type does not match with license product type or application is not bound to the given license key.
int ERROR_INVALID_LICENSE Indicates that an invalid license was used in the operation.
int ERROR_INVALID_PACKAGE_NAME Indicates that the license is missing binding to the calling application.
int ERROR_LICENSE_ACTIVATION_NOT_FOUND Indicates that the activation for the device and license was not found.
int ERROR_LICENSE_DEACTIVATED Indicates that the license used in the operation is not active.
int ERROR_LICENSE_EXPIRED Indicates that the license used in the operation is expired.
int ERROR_LICENSE_QUANTITY_EXHAUSTED Indicates that the license used in the operation does not have available seats.
int ERROR_LICENSE_QUANTITY_EXHAUSTED_ON_AUTO_RELEASE Indicates that this device was deactivated from this license due to not validate the license for a long time (automatic seat count release - ASR) and now the license does not have available seats.
int ERROR_LICENSE_TERMINATED Indicates that the license used in the operation is in the terminated status and could not be used.
int ERROR_NETWORK_DISCONNECTED Indicates whether device network connectivity does not exist.
int ERROR_NETWORK_GENERAL Indicates that a network error occurred during the operation.
int ERROR_NONE Indicates that the operation was successfully performed.
int ERROR_NOT_CURRENT_DATE Indicates that device date is different than current date.
int ERROR_NULL_PARAMS Indicates that some operation parameter is invalid.
int ERROR_SIGNATURE_MISMATCH Indicates that the caller package has an invalid signature.
int ERROR_UNKNOWN Indicates that an unexpected error occurred during operation.
int ERROR_USER_DISAGREES_LICENSE_AGREEMENT Indicates that Knox End User License Agreement was not accepted.
String EXTRA_LICENSE_ERROR_CODE Used as an integer extra field with ACTION_LICENSE_STATUS.
String EXTRA_LICENSE_GRANTED_PERMISSIONS Used as StringArrayList extra field with ACTION_LICENSE_STATUS.
String EXTRA_LICENSE_RESULT_TYPE Used as integer extra field with ACTION_LICENSE_STATUS.
String EXTRA_LICENSE_STATUS Deprecated Not supported since KNOX 3.2. Use EXTRA_LICENSE_ERROR_CODE to check status.
int LICENSE_RESULT_TYPE_ACTIVATION Indicates that this result refers to a Knox Enterprise license activation.
int LICENSE_RESULT_TYPE_DEACTIVATION Indicates that this result refers to a Knox Enterprise license de-activation.
int LICENSE_RESULT_TYPE_VALIDATION Indicates that this result refers to a Knox Enterprise license validation.
Public Methods
void activateLicense(String knoxLicenseKey, String pkgName, LicenseResultCallback callback)
Deprecated in API level 37
NOTE: Applications can use activateLicense(String, LicenseResultCallback) since Android 14 to achieve the same result of this API.
void activateLicense(String knoxLicenseKey)
API to activate a Knox Enterprise license to the calling application with result sent via broadcast.
void activateLicense(String knoxLicenseKey, LicenseResultCallback callback)
API to activate Knox Enterprise license to the calling application with result sent via callback.
void activateLicense(String knoxLicenseKey, String pkgName)
Deprecated in API level 37
NOTE: Applications can use activateLicense(String) since Android 14 to achieve the same result of this API.
void deActivateLicense(String knoxLicenseKey, LicenseResultCallback callback)
API to de-activate Knox Enterprise license to the calling application with result sent via callback.
void deActivateLicense(String knoxLicenseKey)
API to de-activate a Knox Enterprise license to the calling application with result sent via broadcast.
void deActivateLicense(String knoxLicenseKey, String pkgName)
Deprecated in API level 37
NOTE: Applications can use deActivateLicense(String) since Android 14 to achieve the same result of this API.
void deActivateLicense(String knoxLicenseKey, String pkgName, LicenseResultCallback callback)
Deprecated in API level 37
NOTE: Applications can use deActivateLicense(String, LicenseResultCallback) since Android 14 to achieve the same result of this API.
static KnoxEnterpriseLicenseManager getInstance(Context context)
API to create an instance of KnoxEnterpriseLicenseManager class.
ActivationInfo getLicenseActivationInfo()
API to get activation details of KLM activation from calling package.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_LICENSE_STATUS

Since: API level 7

Broadcast Action : Sent to inform about result of Knox License activation, deactivation or validation. This targeted broadcast is sent only to the application who called the activateLicense(String) API. Also system does periodic validation of KNOX license, administrator continuously needs to listen for this intent after activation. The intent will have the following extra value:
EXTRA_LICENSE_STATUS:
"success", "fail".

EXTRA_LICENSE_ERROR_CODE:
ERROR_NONE
ERROR_NULL_PARAMS
ERROR_UNKNOWN
ERROR_INVALID_LICENSE
ERROR_LICENSE_TERMINATED
ERROR_INTERNAL
ERROR_INTERNAL_SERVER
ERROR_NETWORK_DISCONNECTED
ERROR_NETWORK_GENERAL
ERROR_USER_DISAGREES_LICENSE_AGREEMENT
ERROR_LICENSE_DEACTIVATED
ERROR_LICENSE_EXPIRED
ERROR_LICENSE_QUANTITY_EXHAUSTED
ERROR_INVALID_PACKAGE_NAME
ERROR_LICENSE_ACTIVATION_NOT_FOUND

EXTRA_LICENSE_RESULT_TYPE:
LICENSE_RESULT_TYPE_ACTIVATION
LICENSE_RESULT_TYPE_VALIDATION
LICENSE_RESULT_TYPE_DEACTIVATION

EXTRA_LICENSE_GRANTED_PERMISSIONS

Since
API level 7
KNOX 1.0.1
Constant Value: "com.samsung.android.knox.intent.action.KNOX_LICENSE_STATUS"

public static final int ERROR_ANOTHER_PROCESS_IN_PLACE

Since: API level 35

Indicates that the calling package is already activating/deactivating a license key and must wait the result to try again.

Since
API level 35
KNOX 3.8
Constant Value: 602 (0x0000025a)

public static final int ERROR_INTERNAL

Since: API level 7

Indicates that an unexpected error occurred during operation.

Since
API level 7
KNOX 1.0.1
Constant Value: 301 (0x0000012d)

public static final int ERROR_INTERNAL_SERVER

Since: API level 7

Indicates that an unexpected error occurred in license server during operation.

Since
API level 7
KNOX 1.0.1
Constant Value: 401 (0x00000191)

public static final int ERROR_INVALID_BINDING

Since: API level 26

Either the application product type does not match with license product type or application is not bound to the given license key.

Since
API level 26
KNOX 3.2
Constant Value: 208 (0x000000d0)

public static final int ERROR_INVALID_LICENSE

Since: API level 7

Indicates that an invalid license was used in the operation.

Since
API level 7
KNOX 1.0.1
Constant Value: 201 (0x000000c9)

public static final int ERROR_INVALID_PACKAGE_NAME

Since: API level 10

Indicates that the license is missing binding to the calling application.

Since
API level 10
KNOX 1.2.0
Constant Value: 204 (0x000000cc)

public static final int ERROR_LICENSE_ACTIVATION_NOT_FOUND

Since: API level 10

Indicates that the activation for the device and license was not found.

Since
API level 10
KNOX 1.2.0
Constant Value: 703 (0x000002bf)

public static final int ERROR_LICENSE_DEACTIVATED

Since: API level 7

Indicates that the license used in the operation is not active.

Since
API level 7
KNOX 1.0.1
Constant Value: 700 (0x000002bc)

public static final int ERROR_LICENSE_EXPIRED

Since: API level 7

Indicates that the license used in the operation is expired.

Since
API level 7
KNOX 1.0.1
Constant Value: 701 (0x000002bd)

public static final int ERROR_LICENSE_QUANTITY_EXHAUSTED

Since: API level 7

Indicates that the license used in the operation does not have available seats.

Since
API level 7
KNOX 1.0.1
Constant Value: 702 (0x000002be)

public static final int ERROR_LICENSE_QUANTITY_EXHAUSTED_ON_AUTO_RELEASE

Since: API level 26

Indicates that this device was deactivated from this license due to not validate the license for a long time (automatic seat count release - ASR) and now the license does not have available seats.

Since
API level 26
KNOX 3.2
Constant Value: 704 (0x000002c0)

public static final int ERROR_LICENSE_TERMINATED

Since: API level 7

Indicates that the license used in the operation is in the terminated status and could not be used.

Since
API level 7
KNOX 1.0.1
Constant Value: 203 (0x000000cb)

public static final int ERROR_NETWORK_DISCONNECTED

Since: API level 7

Indicates whether device network connectivity does not exist.

Since
API level 7
KNOX 1.0.1
Constant Value: 501 (0x000001f5)

public static final int ERROR_NETWORK_GENERAL

Since: API level 7

Indicates that a network error occurred during the operation.

Since
API level 7
KNOX 1.0.1
Constant Value: 502 (0x000001f6)

public static final int ERROR_NONE

Since: API level 7

Indicates that the operation was successfully performed.

Since
API level 7
KNOX 1.0.1
Constant Value: 0 (0x00000000)

public static final int ERROR_NOT_CURRENT_DATE

Since: API level 10

Indicates that device date is different than current date.

Since
API level 10
KNOX 1.2.0
Constant Value: 205 (0x000000cd)

public static final int ERROR_NULL_PARAMS

Since: API level 7

Indicates that some operation parameter is invalid.

Since
API level 7
KNOX 1.0.1
Constant Value: 101 (0x00000065)

public static final int ERROR_SIGNATURE_MISMATCH

Since: API level 36

Indicates that the caller package has an invalid signature. Check license binding.

Since
API level 10
KNOX 1.2.0
Constant Value: 206 (0x000000ce)

public static final int ERROR_UNKNOWN

Since: API level 7

Indicates that an unexpected error occurred during operation.

Since
API level 7
KNOX 1.0.1
Constant Value: 102 (0x00000066)

public static final int ERROR_USER_DISAGREES_LICENSE_AGREEMENT

Since: API level 7

Indicates that Knox End User License Agreement was not accepted.

Since
API level 7
KNOX 1.0.1
Constant Value: 601 (0x00000259)

public static final String EXTRA_LICENSE_ERROR_CODE

Since: API level 7

Used as an integer extra field with ACTION_LICENSE_STATUS. Contains the error code of Knox license activation or validation result. In case of success, this extra will contain ERROR_NONE.

Since
API level 7
KNOX 1.0.1
Constant Value: "com.samsung.android.knox.intent.extra.KNOX_LICENSE_ERROR_CODE"

public static final String EXTRA_LICENSE_GRANTED_PERMISSIONS

Since: API level 30

Used as StringArrayList extra field with ACTION_LICENSE_STATUS. Contains the list of permissions given after an activation or validation.

Since
API level 30
KNOX 3.4.1
Constant Value: "com.samsung.android.knox.intent.extra.LICENSE_GRANTED_PERMISSIONS"

public static final String EXTRA_LICENSE_RESULT_TYPE

Since: API level 7

Used as integer extra field with ACTION_LICENSE_STATUS. This will tell whether this is activation, validation or deactivation result.

Since
API level 7
KNOX 1.0.1
Constant Value: "com.samsung.android.knox.intent.extra.KNOX_LICENSE_RESULT_TYPE"

public static final String EXTRA_LICENSE_STATUS

Since: API level 7

Deprecated Not supported since KNOX 3.2. Use EXTRA_LICENSE_ERROR_CODE to check status.

Used as String extra field with ACTION_LICENSE_STATUS. Contains the result of the Knox license activation or validation.

Since
API level 7
KNOX 1.0.1
Constant Value: "com.samsung.android.knox.intent.extra.KNOX_LICENSE_STATUS"

public static final int LICENSE_RESULT_TYPE_ACTIVATION

Since: API level 7

Indicates that this result refers to a Knox Enterprise license activation.

Since
API level 7
KNOX 1.0.1
Constant Value: 800 (0x00000320)

public static final int LICENSE_RESULT_TYPE_DEACTIVATION

Since: API level 10

Indicates that this result refers to a Knox Enterprise license de-activation.

Since
API level 10
KNOX 1.2.0
Constant Value: 802 (0x00000322)

public static final int LICENSE_RESULT_TYPE_VALIDATION

Since: API level 7

Indicates that this result refers to a Knox Enterprise license validation.

Since
API level 7
KNOX 1.0.1
Constant Value: 801 (0x00000321)

Public Methods

public void activateLicense (String knoxLicenseKey, String pkgName, LicenseResultCallback callback)

Since: API level 35

Deprecated in API level 37
NOTE: Applications can use activateLicense(String, LicenseResultCallback) since Android 14 to achieve the same result of this API.

API to activate Knox Enterprise license to the calling application with result sent via callback.

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 String knoxLicenseKey = "KLM11-.....";
 mgr.activateLicense(knoxLicenseKey, context.getPackageName(), (licenseResult) -> {
     Log.w("License result arrived.");
 });
 

Parameters
knoxLicenseKey provided by the calling application
pkgName package name of the application calling this API.
callback called when results are ready
Since
API level 35
KNOX 3.8

public void activateLicense (String knoxLicenseKey)

Since: API level 7

API to activate a Knox Enterprise license to the calling application with result sent via broadcast. This targeted broadcast is sent only to the application who called this API.

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 String knoxLicenseKey = "KLM11-.....";
 mgr.activateLicense(knoxLicenseKey);
 

NOTE:

The result of license activation is then notified through an intent ACTION_LICENSE_STATUS.

Parameters
knoxLicenseKey provided by the calling application
Since
API level 7
KNOX 1.0.1

public void activateLicense (String knoxLicenseKey, LicenseResultCallback callback)

Since: API level 35

API to activate Knox Enterprise license to the calling application with result sent via callback.

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 String knoxLicenseKey = "KLM11-.....";
 mgr.activateLicense(knoxLicenseKey, (licenseResult) -> {
     Log.w("License result arrived.");
 });
 

Parameters
knoxLicenseKey provided by the calling application
callback called when results are ready
Since
API level 35
KNOX 3.8

public void activateLicense (String knoxLicenseKey, String pkgName)

Since: API level 11

Deprecated in API level 37
NOTE: Applications can use activateLicense(String) since Android 14 to achieve the same result of this API.

API to activate a Knox Enterprise license to the calling application with result sent via broadcast. This targeted broadcast is sent only to the application who called this API.

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 String licenseKey = "KLM11-.....";
 mgr.activateLicense(licenseKey, context.getPackageName());
 

NOTE:

The result of license activation is then notified through an intent ACTION_LICENSE_STATUS.

Parameters
knoxLicenseKey provided by the calling application
pkgName package name of the calling application
Since
API level 11
KNOX 2.0

public void deActivateLicense (String knoxLicenseKey, LicenseResultCallback callback)

Since: API level 35

API to de-activate Knox Enterprise license to the calling application with result sent via callback.

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 String knoxLicenseKey = "KLM11-.....";
 mgr.deActivateLicense(knoxLicenseKey, (licenseResult) -> {
     Log.w("License result arrived.");
 });
 

Parameters
knoxLicenseKey provided by the calling application
callback called when results are ready
Since
API level 35
KNOX 3.8

public void deActivateLicense (String knoxLicenseKey)

Since: API level 10

API to de-activate a Knox Enterprise license to the calling application with result sent via broadcast. This targeted broadcast is sent only to the application who called this API.

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 String knoxLicenseKey = "KLM11-.....";
 mgr.deActivateLicense(knoxLicenseKey);
 

NOTE:

The result of license de-activation is then notified through an intent ACTION_LICENSE_STATUS.

Parameters
knoxLicenseKey provided by the calling application
Since
API level 10
KNOX 1.2.0

public void deActivateLicense (String knoxLicenseKey, String pkgName)

Since: API level 11

Deprecated in API level 37
NOTE: Applications can use deActivateLicense(String) since Android 14 to achieve the same result of this API.

API to de-activate Knox Enterprise license to the calling application with result sent via broadcast. This targeted broadcast is sent only to the application who called this API.

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 String knoxLicenseKey = "KLM11-.....";
 mgr.deActivateLicense(knoxLicenseKey, context.getPackageName());
 

NOTE:

The result of license activation is then notified through an intent ACTION_LICENSE_STATUS.

Parameters
knoxLicenseKey provided by the calling application
pkgName package name of the application calling this API.
Since
API level 11
KNOX 2.0

public void deActivateLicense (String knoxLicenseKey, String pkgName, LicenseResultCallback callback)

Since: API level 35

Deprecated in API level 37
NOTE: Applications can use deActivateLicense(String, LicenseResultCallback) since Android 14 to achieve the same result of this API.

API to de-activate Knox Enterprise license to the calling application with result sent via callback.

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 String knoxLicenseKey = "KLM11-.....";
 mgr.deActivateLicense(knoxLicenseKey, context.getPackageName(), (licenseResult) -> {
     Log.w("License result arrived.");
 });
 

Parameters
knoxLicenseKey provided by the calling application
pkgName package name of the application calling this API.
callback called when results are ready
Since
API level 35
KNOX 3.8

public static KnoxEnterpriseLicenseManager getInstance (Context context)

Since: API level 7

API to create an instance of KnoxEnterpriseLicenseManager class.

Parameters
context context of the application or service using this class
Returns
Usage
Used to get access to KnoxEnterpriseLicenseManager object

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 
Since
API level 7
KNOX 1.0.1

public ActivationInfo getLicenseActivationInfo ()

Since: API level 33

API to get activation details of KLM activation from calling package.

 KnoxEnterpriseLicenseManager mgr = KnoxEnterpriseLicenseManager.getInstance(context);
 ActivationInfo callerActivationInfo = mgr.getLicenseActivationInfo();
 

Returns
Since
API level 33
KNOX 3.7