# How to Use the SDK ## Adding the SDK 1. Navigate to `app` -> `libs` -> right-click -> select `Open in Finder`. ```{image} ../images/image3.png :width: 700px ``` 1. In the popup window, select the `libs` folder and paste `A24D-SDK.aar` into this folder. `A24D-SDK.aar` will then appear under the project's `libs`. ```{image} ../images/image9.png :width: 700px ``` 1. Double-click `build.gradle`. ```{image} ../images/image10.png :width: 350px ``` 1. Import the library in the dependencies section. Then click `Sync Now` to synchronize the project. ```{image} ../images/image11.png :width: 700px ``` 1. Once the synchronization is successful, it will be displayed as below. The SDK is now added. ```{image} ../images/image12.png :width: 350px ``` ## Using the SDK Reference the library in the class using the `import` statement. ```java import jp.co.asterisk.asreader.a24d.sdk.AsReader; ``` Create and initialize the `AsReader` object. ```java AsReader.getInstance().initialize(getApplicationContext(), ConnectionType.USB); ``` Implement `DeviceManagerCallback` to execute other commands after a successful connection. ```java AsReader.getInstance().getDeviceManager().setCallback(new DeviceManagerCallback() { @Override public void onConnect(boolean isConnect) { } @Override public void onBatteryStateReceived(int battery) { } @Override public void onTriggerEventReceived(DeviceConst.DeviceTriggerEvent event){ } @Override public void onDeviceManagerError(AsReaderError.ErrorCode code) { } }); ``` Implement `BarcodeManagerCallback` to receive barcode decoding results via callback. ```java AsReader.getInstance().getBarcodeManager().setCallback(new BarcodeManagerCallback() { @Override public void onReceivedBarcodeDecodeData(String decodeData, Map parameter) { } @Override public void onBarcodeManagerError { } }); ``` Start barcode decoding: ```java if (AsReader.getInstance().getDeviceManager().isConnected()) { AsReader.getInstance().getBarcodeManager().startDecode(); } ```