# V2 AppLicenseChecker

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

&#x20;   ↳ com.onestore.extern.licensing.AppLicenseChecker<br>

ALC Library和使用者應用程式代碼間通訊的主要通訊埠。

```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 {
    ...
}
```

設定透過AppLicenseChecker.get()接收 publicKey和回應結果之 LicenseCheckerListener。

### Summary <a href="#id-shuo-ming-v2applicensecheckersummary" id="id-shuo-ming-v2applicensecheckersummary"></a>

***

| Nested classes |                                                                                                        |
| -------------- | ------------------------------------------------------------------------------------------------------ |
| @interface     | [ResponseCode](https://dev.onestore.co.kr/wiki/ko/doc/v2-applicensechecker-responsecode-39945654.html) |

### Public methods <a href="#id-shuo-ming-v2applicensecheckerpublicmethods" id="id-shuo-ming-v2applicensecheckerpublicmethods"></a>

***

### get <a href="#id-shuo-ming-v2applicensecheckerget" id="id-shuo-ming-v2applicensecheckerget"></a>

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

<br>

生成AppLicenseChecker的instance

| Parameters:       |                                                                                                                                                                                                                                                                                      |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| context           | 使用於透過 applicationContext 與登錄模組連接。                                                                                                                                                                                                                                                    |
| base64PublicKey   | base64PublicKey                                                                                                                                                                                                                                                                      |
| listener          | [LicenseChecker](http://172.21.139.64:8090/wiki/en/pages/viewpage.action?pageId=38077706)[LicenseCheckerListener](https://dev.onestore.co.kr/wiki/ko/doc/v2-licensecheckerlistener-39945662.html)[Listener](http://172.21.139.64:8090/wiki/en/pages/viewpage.action?pageId=38077706) |
| Returns:          |                                                                                                                                                                                                                                                                                      |
| AppLicenseChecker |                                                                                                                                                                                                                                                                                      |

### queryLicense <a href="#id-shuo-ming-v2applicensecheckerquerylicense" id="id-shuo-ming-v2applicensecheckerquerylicense"></a>

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

<br>

呼叫queryLicense API時，同時進行緩存快取策略。\
&#x20;一般情况下，透過ONE store伺服器接收使用者購買記錄的License，但無法造訪ONE store伺服器時，使用本地緩存快取License訊息以確保有效期限內正常運作。\
考慮網路問題或使用飛航模式的客戶，建議使用相應的 API 。

### strictQueryLicense <a href="#id-shuo-ming-v2applicensecheckerstrictquerylicense" id="id-shuo-ming-v2applicensecheckerstrictquerylicense"></a>

```
@AnyThread
public abstract void strictQueryLicense()

呼叫strictQueryLicense API時，不使用換存快取的授權訊息。 因為無法造訪 ONE store伺服器，使用者無法使用應用程式 。
```

### destroy <a href="#id-shuo-ming-v2applicensecheckerdestroy" id="id-shuo-ming-v2applicensecheckerdestroy"></a>

```
@AnyThread
public abstract void destroy()

中斷與ONE store伺服器連接
```

<br>
