> For the complete documentation index, see [llms.txt](https://docs.licensespring.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.licensespring.com/sdks/android-sdk/licensemanager.md).

# LicenseManager

After completing [**SDK Initialization**](broken://pages/1904f3c851b1bfac2baf8fbaeab6af9bb39f382a), there are a number of methods and objects available to the app developer.

## getCurrent()

In case no active license is available the property value will be null.

```java
License currentLicense = licenseManager.getCurrent();
```

## getTrialLicense(String email)

You can generate a trial key directly from the app using the SDK, which will automatically associate this license key with the provided email. You can later use this data from the LicenseSpring platform to send out email campaigns targeting trial users for example.

{% hint style="danger" %}
After you generate a trial key - the `UnactivatedTrialLicense` object will be returned, you still need to activate it using a call to `licenseManager.activateLicense()`
{% endhint %}

```java
try {
  UnactivatedTrialLicense trial = licenseManager.getTrialLicense("someemail@gmail.com");
  License license = licenseManager.activateLicense(trial.createIdentity());
}
catch(LicenseSpringException e)
{
  log.error("Something went wrong",e);
  return;
}
```

## activateLicenseKey(ActivationLicense identity)

Attempts to activate the product using provided `ActivationIdentity`. Returns the `License` object that has been activated.

```java
// keybased
ActivationLicense keyBased = ActivationLicense.fromKey("license-key");
License activated = licenseManager.activateLicense(keyBased);

// OR username/pass based - Note that this is the only API which requires the password.
// LicenseSpring will never store user passwords via the SDK.
ActivationLicense userBased = ActivationLicense.fromUsername("username", "password");
License activated = licenseManager.ActivateLicense(userBased);
```

## deactivateLicense(LicenseIdentity identity)

License is deactivated using a method on the Manager. You need to supply the current license identity.

```java
boolean isDeactivated = licenseManager.deactivateLicense(LicenseIdentity.fromKey("sample-key"));
```

## getInstallationFile(LicenseIdentity identity)

Returns the latest valid installation file, if installation files are defined in the LicenseSpring platform. For more details please see [**Product Versioning**](broken://pages/d171dd351a681d5cfed18190f8c2c49f446f30ce)

```java
InstallationFile installationFile = licenseManager.getInstallationFile(LicenseIdentity.fromKey("sample-key"));
```

## getVersions(LicenseIdentity identity)

Returns all available versions of the product app that are specified in LicenseSpring platform. For more details please see [**Product Versioning**](broken://pages/d171dd351a681d5cfed18190f8c2c49f446f30ce). Version class only contains String version.

## trackVariables(LicenseIdentity identity, Map\<String, String> variables)

Tracks device based variables for end uses. Can use the `Variable builder` as a utility.

```java
// build your own Map
licenseManager.trackVariables(LicenseIdentity.fromKey("sample-key"), new HashMap<>);

// use utility class to add some variables and track them
DeviceVariables deviceVars = DeviceVariables.builder()
                .variable("one", "some value")
                .variable("another_var", "other_value")
                .build();

licenseManager.trackVariables(LicenseIdentity.fromKey("sample-key"), deviceVars.getVariables());
```

## getProduct()

Gets product details from LicenseSpring servers.

```java
Product product = licenseManager.getProductDetails();
log.info(product.getProductName());
log.info(product.getShortCode());
log.info(product.isAllowTrial());
log.info(product.getTrialDays());
log.info(product.getAuthorizationMethod());
```

## getAirGapActivationCode

Gets the activation code used for air-gapped license.

Needs the `LicenseSpringConfiguration` field: `airGappedPublicKey` to work with Air Gap Licenses.

```java
AirGappedActivation activation = licenseManager.getAirGapActivationCode(
	LicenseIdentity.fromKey("sample-key"), "initializationCodeFromPlatform"
);

log.info(activation.getActivationCode());
log.info(activation.getHardwareId());
log.info(activation.getLicenseKey());
```

## activateAirGapResponse

Activates the air-gapped license from the license policy file.

Needs the `LicenseSpringConfiguration` field: `airGappedPublicKey` to work with `Air Gap Licenses`.

```java
License license = licenseManager.activateAirGapResponse(
	LicenseIdentity.fromKey("sample-key"), 
  	"pathToPolicyFile",
    "policyId"
);

log.info(license.getHardwareId());
log.info(license.getIdentity().getLicenseKey());
```

## verifyAirGapConfirmationCode

Verifies the confirmation code for air-gapped license.

Needs the `LicenseSpringConfiguration` field: `airGappedPublicKey` to work with `Air Gap Licences`.

```java
boolean verified = licenseManager.verifyAirGapConfirmationCode(
	LicenseIdentity.fromKey("sample-key"), 
  	"policyIdFromPlatform",
    "confirmationCodeFromPlatform"
);

log.info(verified);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.licensespring.com/sdks/android-sdk/licensemanager.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
