How to Use the SDK

Adding the SDK

  1. Navigate to app -> libs -> right-click -> select Open in Finder.

    _images/image3.png
  2. 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.

    _images/image9.png
  3. Double-click build.gradle.

    _images/image10.png
  4. Import the library in the dependencies section.
    Then click Sync Now to synchronize the project.

    _images/image11.png
  5. Once the synchronization is successful, it will be displayed as below.
    The SDK is now added.

    _images/image12.png

Using the SDK

Reference the library in the class using the import statement.

import jp.co.asterisk.asreader.a24d.sdk.AsReader;

Create and initialize the AsReader object.

AsReader.getInstance().initialize(getApplicationContext(), ConnectionType.USB);

Implement DeviceManagerCallback to execute other commands after a successful connection.

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.

AsReader.getInstance().getBarcodeManager().setCallback(new BarcodeManagerCallback() {
    @Override
    public void onReceivedBarcodeDecodeData(String decodeData, Map<String, String> parameter) {
        
    }

    @Override
    public void onBarcodeManagerError {

    }
});

Start barcode decoding:

if (AsReader.getInstance().getDeviceManager().isConnected()) {
    AsReader.getInstance().getBarcodeManager().startDecode();
}