LicenseManager
The LicenseManager class provides a set of APIs to manage SDK licensing.
Definition
Namespace: com.dynamsoft.license
public class LicenseManager
Methods
| Method | Description |
|---|---|
initLicense |
Initializes the license using a license key. |
setDeviceFriendlyName |
Sets the friendly name of the device. |
setMaxConcurrentInstanceCount |
Sets the maximum number of allowed instances for the given device and process. |
getDeviceUUID |
Gets the unique identifier of the device. |
setLicenseCachePath |
Sets the directory path for the license cache. |
initLicense
Initializes the license using a license key.
static LicenseError initLicense(String license) throws LicenseException
Parameters
license The license key as a string.
Return Value
Returns a LicenseError object containing error information.
Exception
See Also
setDeviceFriendlyName
Sets the friendly name of the device.
static void setDeviceFriendlyName(String name) throws LicenseException
Parameters
name The friendly name of the device.
Exception
Remarks
This function must be called before function initLicense to ensure correct functionality.
See Also
setMaxConcurrentInstanceCount
Sets the maximum number of allowed instances for the given device.
static void setMaxConcurrentInstanceCount(int countForThisDevice) throws LicenseException
Parameters
countForThisDevice The maximum number of allowed instances for the device.
Exception
Remarks
This function must be called before function initLicense to ensure correct functionality.
See Also
getDeviceUUID
Gets the unique identifier of the device.
static char[] getDeviceUUID(int uuidGenerationMethod) throws LicenseException
Parameters
uuidGenerationMethod The method to generate the UUID.
- 1: Generates UUID with random values.
- 2: Generates UUID based on hardware info.
Return Value
Returns a char array representing the unique identifier of the device.
Exception
Remarks
This function must be called before function initLicense to ensure correct functionality.
setLicenseCachePath
Sets the directory path for the license cache.
static void setLicenseCachePath(String directoryPath) throws LicenseException
Parameters
directoryPath The directory path for the license cache.
Exception
Remarks
This function must be called before function initLicense to ensure correct functionality.
See Also
Code Snippet
try {
LicenseManager.setLicenseCachePath("DIRECTORY-PATH-FOR-LICENSE-CACHE");
char[] deviceUUID = LicenseManager.getDeviceUUID(1);
LicenseManager.setDeviceFriendlyName("FRIENDLY-NAME");
LicenseError licenseError = LicenseManager.initLicense("YOUR-LICENSE-KEY");
if (licenseError.getErrorCode() != EnumErrorCode.EC_OK &&
licenseError.getErrorCode() != EnumErrorCode.EC_LICENSE_CACHE_USED) {
System.out.println("License initialization error: " + licenseError.getErrorString());
} else {
CaptureVisionRouter cvrInstance = new CaptureVisionRouter();
// add code for further process
}
} catch (LicenseException e) {
e.printStackTrace();
}