Hi,
I am having an issue with receiving license events after activating a license key. It seems that synchronization with the server stops working after the license is activated. I am using the library version 3.28.1.
Case 1: The application starts with an already active license
I launch the application. The application already has an entered license, so during initialization, the IsLicenseGenuine() method returns LA_OK and everything works fine. The application runs with the active license. Then, I change the license status in the dashboard to “Suspended” and after 180 seconds, I receive an event with the LA_SUSPENDED status, which is expected. The application receives this event and the LicenseCallback() method handles it correctly.
Case 2: The application has no license and activates one
I launch the application. The application has no license. I enter the license key and call the ActivateLicense() method, which returns the LA_OK status. Then, just like before, I change the license status in the dashboard to “Suspended.” Despite waiting for about 10 minutes, I do not receive any event.
I would expect to receive events about any status changes in both cases. What am I doing wrong?
To better understand the steps I am taking, I have attached the code:
public void initialize() throws LicenseException {
try {
initializeLicenseProductData();
LicenseCallbackEventListener licenseEventListener = new LicenseCallbackEventListener();
LexActivator.SetLicenseCallbackListener(licenseEventListener);
int status = LexActivator.IsLicenseGenuine();
switch (status) {
case LexActivator.LA_OK -> handleLicenseGranted();
case LexActivator.LA_EXPIRED -> handleLicenseExpired();
case LexActivator.LA_GRACE_PERIOD_OVER -> handleLicenseGracePeriodOver();
case LexActivator.LA_SUSPENDED -> handleLicenseSuspended();
default -> {
int trialStatus = LexActivator.IsTrialGenuine();
switch (trialStatus) {
case LexActivator.LA_OK -> handleTrialGranted();
case LexActivator.LA_TRIAL_EXPIRED -> handleTrialExpired();
default -> handleNoLicense();
}
}
}
} catch (LexActivatorException | IOException e) {
throw new LicenseException(e);
}
}
public void activateLicense(String licenseKey) throws LicenseException {
try {
LexActivator.SetLicenseKey(licenseKey);
int status = LexActivator.ActivateLicense();
switch (status) {
case LexActivator.LA_OK -> handleLicenseGranted();
case LexActivator.LA_EXPIRED -> handleLicenseExpired();
case LexActivator.LA_GRACE_PERIOD_OVER -> handleLicenseGracePeriodOver();
case LexActivator.LA_SUSPENDED -> handleLicenseSuspended();
default -> handleLicenseActivationFailure(status);
}
} catch (LexActivatorException e) {
throw new LicenseException("Error during license activation: ", e);
}
}
class LicenseCallbackEventListener implements LicenseCallbackEvent {
@Override
public void LicenseCallback(int status) {
switch (status) {
case LexActivator.LA_OK:
LOGGER.info("LicenseCallback: The license has been activated.");
break;
case LexActivator.LA_EXPIRED:
LOGGER.info("LicenseCallback: The license has been expired.");
break;
case LexActivator.LA_SUSPENDED:
LOGGER.info("LicenseCallback: The license has been suspended.");
break;
default:
LOGGER.warn(LexActivatorException.getErrorMessage(status));
break;
}
}
}
Thank you for your help!