# V2 AppLicenseChecker

```
public abstract class AppLicenseChecker extends Object
java.lang.Object
```

&#x20;   ↳ com.onestore.extern.licensing.AppLicenseChecker

<br>

This is the primary interface for communication between the ALC library and the user application code.&#x20;

```java
class YourActivity extends AppCompatActivity {
     private AppLicensChecker mAppLicenseChecker;      
     
     @Override
     protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...
        mAppLicenseChecker = AppLicenseChecker.get(MainActivity.this, getString(R.string.publick_key, new AppLicenseListener());
    }
...
}
 
private class AppLicenseListener implements LicenseCheckerListener {
    ...
}
```

| `class` `YourActivity extends` `AppCompatActivity {     private` `AppLicensChecker mAppLicenseChecker;` `@Override     protected` `void` `onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        ...        mAppLicenseChecker = AppLicenseChecker.get(MainActivity.this, getString(R.string.publick_key, new` `AppLicenseListener());    }...}` `private` `class` `AppLicenseListener implements` `LicenseCheckerListener {    ...}` |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

Set the [LicenseCheckerListener](https://onestore-dev.gitbook.io/dev/chi/tools/alc/alc-v2-reference/interfaces_/v2-licensecheckerlistener) to receive the publicKey and response results through AppLicenseChecker.get().

<br>

### Summary <a href="#v2applicensechecker-summary" id="v2applicensechecker-summary"></a>

***

| Nested classes |                                                                                                                                 |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| @interface     | [ResponseCode](https://onestore-dev.gitbook.io/dev/chi/tools/alc/alc-v2-reference/annotation/v2-applicensechecker.responsecode) |

### Public methods <a href="#v2applicensechecker-publicmethods" id="v2applicensechecker-publicmethods"></a>

***

### get <a href="#v2applicensechecker-get" id="v2applicensechecker-get"></a>

```
public static AppLicenseChecker get(Context context, String base64PublicKey, LicenseCheckerListener listener)
```

<br>

Create an instance of the AppLicenseChecker.

| Parameters:       |                                                                                                                                    |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| context           | AppLicenseChecker applicationContent is used to connect to the login module.                                                       |
| base64PublicKey   | base64PublicKey                                                                                                                    |
| listener          | [LicenseCheckerListener](https://onestore-dev.gitbook.io/dev/chi/tools/alc/alc-v2-reference/interfaces_/v2-licensecheckerlistener) |
| Returns:          |                                                                                                                                    |
| AppLicenseChecker |                                                                                                                                    |

### queryLicense <a href="#v2applicensechecker-querylicense" id="v2applicensechecker-querylicense"></a>

```
@AnyThread
public abstract void queryLicense()
```

<br>

When calling the queryLicense API, it will work in conjunction with the cache policy.\
Generally, a user's purchase history license is delivered through the ONE store server, but when access to the ONE store server is not possible due to network failures or airplane mode, a locally cached license is used to ensure execution until the expiration date.

We recommend using this API for customers who have network condition problems or who are on airplane mode.&#x20;

### strictQueryLicense <a href="#v2applicensechecker-strictquerylicense" id="v2applicensechecker-strictquerylicense"></a>

```
@AnyThread
public abstract void strictQueryLicense()

The cached license information is not used when calling the strictQueryLicense API. In this case, the user cannot use the app when the ONE store server is inaccessible. 
```

### destroy <a href="#v2applicensechecker-destroy" id="v2applicensechecker-destroy"></a>

```
@AnyThread
public abstract void destroy()

Disconnecting from the ONE store service. 
```

<br>


---

# Agent Instructions: 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:

```
GET https://onestore-dev.gitbook.io/dev/chi/tools/alc/alc-v2-reference/classes_/v2-applicensechecker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
