SDK Initialization

The SDK behaves as a singleton — initialize it only once and reuse it. As soon as you initialize the SDK, it will contact the LicenseSpring server to check if there is an existing license for the current device / product combination.

If a license is available, it will be immediately accessible as a License object. During initialization the LicenseManager will try to read the license information from the specified license file and validate it with the license server. If successful, LicenseManager.getCurrent() will return a License object with detailed license information.

circle-info

The LicenseManager takes two arguments for initialization: LicenseSpringConfiguration and the application context. The application context is used to save license files to internal app storage.

circle-info

The SDK has a hardware key generator based on the Secure Android ID. If the Secure Android ID is null, a UUID will be used as the hardware key.

circle-exclamation
1

Build configuration

Create a LicenseSpringConfiguration with the required values (and optional app metadata):

LicenseSpringConfiguration initialization
LicenseSpringConfiguration configuration = LicenseSpringConfiguration.builder()
    .apiKey("api_key")
    .productCode("product_code")
    .sharedKey("shared-key")
    .appName("My application")
    .appVersion("1.0.0")
    .build();
2

Initialize LicenseManager

Get the singleton instance and initialize it with the configuration and application context:

LicenseManager initialization
LicenseManager manager = LicenseManager.getInstance();
manager.initialize(configuration, getApplicationContext());

After initialization, the SDK will attempt to read and validate any existing license; if present, it will be exposed via LicenseManager.getCurrent().

Was this helpful?